Introduction to Java Programming, Seventh Edition, Y. Daniel Liang

Chapter 1 Introduction to Computers, Programs, and Java


Section 1.2 What is a Computer?
1  ________ is the physical aspect of the computer that can be seen.

A. Hardware
B. Software
C. Operating system
D. Application program

2  __________ is the brain of a computer.

A. Hardware
B. CPU
C. Memory
D. Disk

3  The speed of the CPU is measured in __________.

A. megabytes
B. gigabytes
C. megahertz
D. gigahertz

4  Why do computers use zeros and ones?

A. because combinations of zeros and ones can represent any numbers and characters.
B. because digital devices have two stable states and it is natural to use one state for 0 and the other for 1.
C. because binary numbers are simplest.
D. because binary numbers are the bases upon which all other number systems are built.

5  One byte has ________ bits.

A. 4
B. 8
C. 12
D. 16

6  Which of the following are storage devices?

A. floppy disk
B. hard disk
C. flash stick
D. CD-ROM

7  ____________ is a device to connect a computer to a local area network (LAN).

A. Regular modem
B. DSL
C. Cable modem
D. NIC

Section 1.3 Programs
8  ____________ are instructions to the computer.

A. Hardware
B. Software
C. Programs
D. Keyboards

9  Computer can execute the code in ____________.

A. machine language
B. assembly language
C. high-level language
D. none of the above

10  ___________ translates high-level language program into machine language program.

A. An assembler
B. A compiler
C. CPU
D. The operating system

Section 1.4 Operating Systems
11  ____________ is an operating system.

A. Java
B. C++
C. Windows XP
D. Visual Basic
E. Ada

12  _____________ is a program that runs on a computer to manage and control a computer's activities.

A. Operating system
B. Java
C. Modem
D. Interpreter
E. Compiler

Section 1.5 Number Systems
13  Decimal number 10 is binary number ____________.

A. 10
B. 2
C. 1000
D. 1100
E. 1010

14  Decimal number 20 is hexadecimal number ____________.

A. A
B. FF
C. F1
D. 14
E. 1F

15  Binary number 1001 is decimal number ____________.

A. 5
B. 9
C. 10
D. 11
E. 12

16  Binary number 1001 is hexadecimal number ____________.

A. 5
B. 9
C. A
D. B
E. C

17  Hexadecimal number A1 is decimal number ____________.

A. 100
B. 101
C. 161
D. 162
E. 163

18  Hexadecimal number A1 is binary number ____________.

A. 10010100
B. 10100001
C. 01100001
D. 11100001
E. 11001001

Section 1.6 Java, World Wide Web, and Beyond
19  Java was developed by ____________.

A. Sun Microsystems
B. Microsoft
C. Oracle
D. IBM
E. Cisco Systems

20  Java ___________ can run from a Web browser.

A. applications
B. applets
C. servlets
D. Micro Edition programs

21  ________ is an object-oriented programming language.

A. Java
B. C++
C. C
D. Ada
E. Pascal

22  ________ is interpreted.

A. Java
B. C++
C. C
D. Ada
E. Pascal

23  ________ is Architecture-Neutral.

A. Java
B. C++
C. C
D. Ada
E. Pascal

Section 1.7 The Java Language Specification, API, JDK, and IDE
24  ________ is a technical definition of the language that includes the syntax and semantics of the Java programming language.

A. Java language specification
B. Java API
C. Java JDK
D. Java IDE

25  ________ contains predefined classes and interfaces for developing Java programs.

A. Java language specification
B. Java API
C. Java JDK
D. Java IDE

26  ________ consists of a set of separate programs for developing and testing Java programs, each of which is invoked from a command line.

A. Java language specification
B. Java API
C. Java JDK
D. Java IDE

27  ________ provides an integrated development environment (IDE) for rapidly developing Java programs. Editing, compiling, building, debugging, and online help are integrated in one graphical user interface.

A. Java language specification
B. Java API
C. Java JDK
D. Java IDE

Section 1.8 A Simple Java Program
28  The main method header is written as:

A. public static void main(string[] args)
B. public static void Main(String[] args)
C. public static void main(String[] args)
D. public static main(String[] args)
E. public void main(String[] args)

29  Which of the following statements is correct?

A. Every line in a program must end with a semicolon.
B. Every statement in a program must end with a semicolon.
C. Every comment line must end with a semicolon;
D. Every method must end with a semicolon;
E. Every class must end with a semicolon;

30  Which of the following statements is correct to display Welcome to Java on the console?

A. System.out.println('Welcome to Java');
B. System.out.println("Welcome to Java");
C. System.println('Welcome to Java');
D. System.out.print('Welcome to Java');
E. System.out.print("Welcome to Java");

Section 1.9 Creating, Compiling, and Executing a Java Program
31  The JDK command to compile a class in the file Test.java is

A. java Test
B. java Test.java
C. javac Test.java
D. javac Test
E. JAVAC Test.java

32  Which JDK command is correct to run a Java application in ByteCode.class?

A. java ByteCode
B. java ByteCode.class
C. javac ByteCode.java
D. javac ByteCode
E. JAVAC ByteCode

33  Java compiler translates Java source code into _________.

A. Java bytecode
B. machine code
C. assembly code
D. another high-level language code

34  _________ is a software that interprets Java bytecode.

A. Java virtual machine
B. Java compiler
C. Java debugger
D. Java API

35  Suppose you define a Java class as follows:

public class Test {

}

In order to compile this program, the source code should be stored in a file named

A. Test.class
B. Test.doc
C. Test.txt
D. Test.java
E. Any name with extension .java

36  The extension name of a Java bytecode file is

A. .java
B. .obj
C. .class
D. .exe

37  The extension name of a Java source code file is

A. .java
B. .obj
C. .class
D. .exe

38  Which of the following lines is not a Java comment?

A. /** comments */
B. // comments
C. -- comments
D. /* comments */
E. ** comments **

39  Which of the following are the reserved words?

A. public
B. static
C. void
D. class

40  Every statement in Java ends with ________.

A. a semicolon (;)
B. a comma (,)
C. a period (.)
D. an asterisk (*)

41  A block is enclosed inside __________.

A. Parentheses
B. Braces
C. Brackets
D. Quotes

Section 1.10 (GUI) Displaying Text in a Message Dialog Box
42  The __________ method displays a message dialog box.

A. JOptionPane.showMessage(null, "Welcome to Java!", "Example 1.2 Output", JOptionPane.INFORMATION_MESSAGE);
B. JOptionPane.displayMessage(null, "Welcome to Java!", "Example 1.2 Output", JOptionPane.INFORMATION_MESSAGE);
C. JOptionPane.displayMessageDialog(null, "Welcome to Java!", "Example 1.2 Output", JOptionPane.INFORMATION_MESSAGE);
D. JOptionPane.showMessageDialog(null, "Welcome to Java!", "Example 1.2 Output", JOptionPane.INFORMATION_MESSAGE);
E. JOptionPane.showMessageDialog(null, "Welcome to Java!");

43  To use JOptionPane in your program, you may import it using:
A. import javax.swing.JOptionPane;
B. import javax.swing.*;
C. import javax.*;
D. import javax.*.JOptionPane;