Sie sind auf Seite 1von 3

Chapter 1 Introduction to Computers, Programs, and Java

1. A computer is an electronic device that stores and processes data. A computer includes both hardware and software. In general, hardware is the physical aspect of the computer that can be seen, and software is the invisible instructions that control the hardware and make it work. The hardware of a computer consists of a CP , cache, memory, hard disk, floppy disk, monitor, printer, and communication devices. !. "ive ma#or hardware components$ CP , %emory, &torage 'evices, Input()ut 'evices, and Communication 'evices. *. CP stands for Central Processing nit. It is the brain of the computer. +. The unit of measurement of clock speed is the hert, -.,/, with 1 hert, e0ualing 1 pulse per second. The clock speed of a computer is usually stated in megahert, -%.,/ -1 %., is 1 million .,/. 1. A bit is a binary digit 2 or 1. A byte is a se0uence of 3 bits. 4. %emory is like a work area for programs. 5efore a program is e6ecuted, it is brought into the memory. 7A% stands for random8access memory. It is called 7A% because a memory cell can be accessed directly. 9. %emory si,e is measured in bytes. 3. 'isk si,e is measured in bytes. :. %emory is volatile, because information is lost when the power is turned off. Programs and data are permanently stored on storage devices and are moved, when the computer actually uses them, to memory, which is much faster than storage devices. 12. The machine language is a set of primitive instructions built into every computer. This is the language understood by a computer and e6ecuted by a computer. 11. Assembly language is a low8level programming language in which a mnemonic is used to represent each of the machine language instructions. 1!. Assembler is a software that translates assembly language into machine language. 1*. The high-level languages are ;nglish8like and easy to learn and program. 1+. The program written in a programming language is called a source program. 11. An interpreter is a software that reads one statement from the source code, translates it to the machine code or virtual machine code, and then e6ecutes it right away 14. A compiler is a software that translates a program in high8level language into machine language code. 19. An interpreter reads one statement from the source code, and translates it to the machine code or virtual machine code, and then e6ecutes it right away. A compiler translates the entire source code into a machine code file, and the machine code file is then e6ecuted. 13. The operating system -)&/ is a program that manages and controls a computer<s activities. The e6amples of )& are =indows :3, >T, !222, ?P, or %;. =indows. Application programs such as an Internet browser and a word processor run on top of an operating system. 1:. %a#or responsibilities$ a. Controlling and monitoring system activities b. Allocating and assigning system resources c. Scheduling operations

!2. %ultiprogramming allows multiple programs to run simultaneously by sharing the CP . %ultithreading allows concurrency within a program, so that its subtasks can run at the same time. %ultiprocessing, or parallel processing, uses two or more processors together to perform a task. !1. @ava was invented by a team led by @ames Aosling at &un %icrosystems in 1::1. )riginally called )ak, it became @ava in 1::1 when it was redesigned for developing Internet applications. )racle bought &un and )racle now owns @ava. !!. @ava applet is a special program that runs from a =eb browser. !*. Android uses the @ava programming language. !+. The @ava language specification specifies the synta6 for the @ava language. !1. @'B stands for @ava 'evelopment Toolkit. !4. I'; stands integrated development environment. !9. >et5eans and ;clipse are not programming languages, nor dialects, nor e6tensions of @ava. They are @ava development tools. !3. Beywords have specific meaning to the compiler and cannot be used for other purposes in the program such as variables or method names. ;6amples of keywords are class, static, and void. !:. @ava source code is case sensitive. @ava keywords are always in lowercase. *2. Comments are used to document what a program is for and how a program is constructed. Comments help the programmers or users to communicate and understand the program. Comments are not programming statements and are ignored by the compiler. In @ava, comments are preceded by two forward slashes -((/ in a line or enclosed between (C and C( in multiple lines. =hen the compiler sees ((, it ignores all te6t after (( in the same line. =hen it sees (C, it scans for the ne6t C( and ignores any te6t between (C and C(. *1. System.out.println(string); *!. )utput is
3.5 * 4 / 2 2.5 is 4.5

**. The source file e6tension is .#ava and the bytecode file e6tension is .class. *+. The input of a @ava compiler is a @ava source code file and the output is a @ava class file. *1. #avac is the @'B command to compile a program. *4. #ava is the @'B command to run a program. *9. @D% is the @ava virtual machine that runs a @ava program. *3. @ava can run on any machine with a @D%. *:. @ava interpreter cannot find the .class file. %ake sure you placed the .class in the right place, and invoked #ava command with appropriate package name. +2. +1. JOptionPane.showMessageDialog(null, E.ello worldF/G +!. The &ystem class is in the #ava.lang package. This package is implicitly imported. &o, there is no need to e6plicitly import it. +*. >o performance difference. The class does not have a main method, or the signature of the main method is incorrect.

++.
public class Test { // Main method public static void main(String[] args) { /** Display outpput */ System.out.println("Welcome to Java"); } }

45.

Synta errors are detected by compilers. !untime errors occur during e ecution o" the program. #ogic errors results in incorrect results. See the te t. Synta error. !untime error. #ogic error. Hine !. %ain should be main. Hine !. static is missing. Hine *$ =elcome to @avaI should be enclosed inside double 0uotation marks. Hine 1$ The last / should be J.

4$. 4%. 4&. 4'. 5(.

5). public class *elcome + public static void main,String-. args/ + System.out.println,0morning0/1 System.out.println,0a"ternoon0/1 2 2

Das könnte Ihnen auch gefallen