1.2 Flashcards
(22 cards)
1.2.4
1) What is string manipulation?
2) What is the command to get a string length?
3) What is the command to extract part of a string?
1) The act of manipulating, extracting, or changing the characters in a string variable.
2) To get the length of the string: stringName.length
3) To extract part of a string: string.substring (starting position, number of characters)
1.2.4
1) What is a procedure?
2) What is a function?
3) How does a return value work?
1) A procedure is a named block of code that performs a task, but does not return a value.
2) A function is a named block of code that returns a value.
3) A return value can be used directly without being assigned to a variable first. Some programming languages allow just one value to be returned, while others support multiple return values.
1.2.4
1) What is a local variable?
2) Can local variables have the same identifier?
1) A local variable is a varible that is only accessible within a specific part of a program. These variables are usually local to a subroutine and are declared or defined within that routine.
2) Local variables in different subroutines are allowed to have the same identifier (name). Each variable’s data is stored in separate places in main memory, so changing the value of a local variable one subroutine will not affect the value of any local variables with the same identifier in their subroutine
1.2.4
1) What is a global variable?
2) Is it better to use local or global variables?
1) A global variable can be accessed anywhere in a program for the duration of the program’s execution. A global variable has a global has a global scope.
2) Programs using global variables are more difficult to debug, as the variables can be updated in any part of the program. It is almost always better to use local variables and to pass values between subroutines to avoid errors caused by unforeseen changes.
1.2.4
1. Define encapsulation
2. Define instantiation
3. Define inheritance
- Encapsulation is bundling together attributes and methods into a class.
- Instantiation is the process of creating an object from a class template. A constructor is a procedure that runs when an object with the class type is created.
- Inheritance is a mechanism that allows an instance of a class to inherit attributes from another class — the parent class.
1.2.4
1. Define subclass
2. Define superclass
3. Define polymorphism
- A subclass is a class that inherits from another class.
- A superclass is the class from which the subclass inherits attributes and methods from.
- Polymorphism is the ability of an entity such as a variable, method or object to have more than one form.
1.2.4
1. Define overloading
2. Define overriding
3. What are the advantages of inheritance?
4. What are the disadvantages of inheritance?
- Overloading is where methods have the same name but different signatures. The signature can differ by the number of parameters, the type of parameters, or both. For example, there can be a function that has one output if the parameter is a string, and the same function can have a different function if the parameter is an integer.
- Overriding is where an inherited method is superseded by a method defined in the subclass. In OOP, this is where the ability for classes that share a common superclass to have different implementations of a method with the same name.
- Reusability and readability. When a child class inherits the properties of a parent class, there is no need to rewrite the code.
- When you inherit from another class, you have coupled the two classes. If the parent class is edited, there could be unwanted or unknown changes to the attributes and methods in the child class.
What is the process for file handling?
- Open the file for reading data,
- Assign a Boolean variable to FALSE to indicate that the end of the file is not reached. While the end of the file is false and the search item is not found:
a. Read the data from the file.
b. If the data matches what is being searched for, assign the data to the variables or output.
c. Check if the end of the file has been reached and assign the Boolean variable to true. - Close the file
- What is the pseudocode to open a file and read one line?
- What is the pseudocode to print all the lines of a text file?
- What is the pseudocode to write text to a text file?
- myFile = openRead(“sample.txt”)
x = myFile.readLine()
myFile.close() - myFile = openRead(“sample.txt”)
while NOT myFile.endOfFile()
print(myFile.readLine())
endwhile
myFile.close() - myFile = openWrite(“sample.txt’)
myFile.writeLine(“Hello World”)
myFile.close()
1.2.4
1. Define accumulator
2. What are the advantages and uses of assembly language?
3. What is the LMC?
- Accumulator - A register (small area of fast memory) which stores the intermediate results of arithmetic and logical (1 or 0) calculations.
- Low level languages are typically used in: embedded systems with minimal resources (eg. washing machines), and real time systems (such as auto-pilot on aircraft). It allows better control over memory and usually runs faster than high level language programs.
- The Little Man Computer (LMC) instruction set uses many of the features of the Von Neumann architecture (RAM to store both data and instructions, a central processing unit consisting of a single arithmetic logic unit, a control unit, buses).
1.2.4
State the LMC commands for the following:
1. Input and output
2. Add and subtract
3. Store and load
- INP, OUT
- ADD, SUB
- STA, LDA
1.2.4
State the LMC commands for the following:
1. End the program
2. Store data
3. Branch always, branch if zero, branch if positive or zero
- HLT
- (Variable name) DAT (data, optional)
- BRA, BRZ, BRP
- What is the BIOS?
- What is the computer boot up process?
- Basic Input Output System - Part of the operating system that provides the sequence and initialisation tasks for the boot-up process.
- Processor logic or a jump instruction starts a BIOS program stored in ROM/EEPROM (flash memory).
A full power-on self-test (POST) is run, this determines if the computer keyboard, RAM, disk drives, and other hardware are working correctly (very quick).
BIOS attempts to locate boot loader software (programming responsible for booting a computer) on a “boot device”, such as a hard disk, a floppy disk, CD, or DVD. The boot loader is a program and part of the operating system.
- Define utility
- Explain the difference between a utility and an application
- Give some examples of utility software
- A utility performs a specific task (1) and is usually related to the upkeep of a system (1).
- An application performs tasks for the user instead of the computer, and performs generic rather than specific tasks.
- A disk defragmenter organises file segments on secondary storage.
A compression utility reduces the size of files.
A backup utility makes regular copies of files in case of loss.
A compression utility reduces the size of files.
Anti-virus, firewall, device driver.
- What are the types of translators?
- What are the advantages and disadvantages of code compiled to intermediate code running off a virtual machine?
- Compilers, assemblers, and interpreters. Compiler translate the entire code into machine code at once, while interpreter translated the code one line at a time.
- With a VM, only one version of the code needs to be written and can be run on any device. However, code running on a virtual machine tends to be slower than compiled. Developers will have limited access to some of the low level features, which can optimise the program. Intermediate code is also used in helping to protect intellectual property.
Explain the following utility software:
1. File handlers
2. Hardware drivers
3. Backup utility
- A file handler manages data storage. It is used for the creation, deletion and sorting of files and folders. It manages the storage of software and allows access to files.
- Hardware drivers enable the peripheral device and operating system to communicate. It is used to configure hardware, for example to install a new keyboard, mouse or printer.
- A backup utility automatically makes a copy of files, storing them in a different location, incase of data loss or corruption. It is used to make incremental backups.
Explain what intermediate code is
Intermediate code is simplified code produced by the compiler that is between high level and machine code. The code runs on any computer, allowing portability between machines. It also allows sections of code to be written in different languages by different programmers, which is suitable for specific tasks.
Explain the purpose of intermediate code in a virtual machine
A virtual machine is a theoretical computer which provides an environment in which a translator is available. A translator is used to convert code from one language to another, or from source code to object code. The three main types are compilers, interpreters and assemblers. It uses an interpreter to run the intermediate code.
- Define open source software
- What are the benefits of open source software rather than closed source software?
- What is the benefit of using open source software as a foundation to create a new software?
- Open source software is where the source code is freely available (1) for others to edit. (1)
- You can modify and adapt the code to meet your needs. It is likely to be financially free of cost. It has the benefit of a community potentially improving the system, and can ensure no backdoors or malware.
- A lot of the core functionality needed is already available, so the company only has to make additions specific to the software, saving time and money.
- What are the functions of an operating system?
- Define assembler
- An operating system: provides a user interface, provides system security, manages hardware and peripherals, manages files and memory, provides utilities for system maintenance.
- An assembler converts assembly language into machine code.
What are the advantages and disadvantages of the following:
1. Compiled code
2. Interpreted code
- With code that is directly compiled to machine code, multiple versions of the code will need to be maintained for different architectures, and compiling with different compilers. However, there may be minimal differences, and program will run quicker than alternatives. Some less used architectures may not be developed for as not commercially viable. Compiled code runs faster, which may be more noticeable on power-extensive tasks.
- Interpreted code is likely to be the slowest option. An example is JavaScript, which can run in any web browser, and as most people have web browsers, so the most compatible translator option. It runs the slowest, but as easily compatible, it may be worth the speed sacrifice. The source code is visible, so it can be easily copied and amended.
Define device driver and give some examples
A device driver is a software that allows the operating system to communicate with hardware. Examples include: printer driver, webcam driver, sound card driver, and graphics card driver.