Marking Scheme for TMA1 Suggested Answer 1. In a high-level programming language, instructions are written in a form that is human-readable, because it is something like ordinary human language. In machine language, instructions are coded as binary numbers. A computer cannot understand high-level programming languages directly – they must be translated into machine language before they can be executed. The computer can directly execute a program that is written in its machine language. 2. The CPU, or Central Processing Unit, is the active part(or brain) of the computer. Its function is to execute programs that are coded in machine language and stored in the main memory (RAM) of the computer. It does this by repeating the fetchand-execute cycle over and over; that is, it repeatedly fetches a machine language instruction from memory and executes it. 3. The “javac” command translates the Java source code into Java “bytecode” instructions, which are stored in the class file. Java bytecode is the machine language fro the “Java Virtual Machine,” a computer that doesn’t actually exist. The program can be executed by running the class file under the “java” command, which is an interpreter for Java bytecode. 4. java is a multiplatform language. That is, programs written in Java can be run on many different types of computer. This is essential for programs that are going to be downloaded over the Internet, since many types of computer are connected to the Net. It allows Java applets to be used on Web pages, and Java gets a lot of its popularity from its association with the Web. Java also has many features that make it a good choice for modern computing. It is object-oriented. It support multithreading, making it easy to write programs that do several things at once. It uses garbage collection for memory management, which frees the programmer from worrying about one of the most common
sources of errors in programs. It has built-in support for a graphical user interface and event-driven programming. 5. The word “public” means that the main routine is visible or accessible from outside the class in which it is defined. It is necessary since main will be called from outside the class (by the system) when the program is executed. 6. a) a class is a blueprint/prototype/general definition from where we can create objects. Classes can specify the attributes and actions that specific members of the class can have. A class example with attribute, “Student” would be a class defining the general characteristics of all students, e.g., a name and a date of birth. b) an object is
specific instance of a class that has specific values fro the
attributes defined in the prototype class definition. For example, in the Student class, specific student would be Mark with a specific name(i.e., Mark) and date of birth(e.g., 30/05/79) 7. for many years, programming languages used the 7-bit ASCII character set, and more recently, the 8-bit Extended ASCII character set. However, Java does not use the ASCII character set. Java characters are expressed as 16-bit Unicode characters.