Ch1 -Introduction to Java Programming, Includes Data Structures, Eleventh Edition, Y. Daniel Liang Chapter 1 Self-Test & Check Point Questions

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

What is a bit? What is a byte?

A bit is a binary digit 0 or 1. A byte is a sequence of 8 bits.

What are hardware and software?

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 CPU, cache, memory, hard disk, floppy disk, monitor, printer, and communication devices.

The extension name of a Java source code file is A. .java B. .obj C. .class D. .exe

A. .java

_ is the physical aspect of the computer that can be seen. A. Hardware B. Software C. Operating system D. Application program

A. Hardware

_ is the physical aspect of the computer that can be seen. A. Hardware B. Software C. Operating system D. Application program

A. Hardware

________ is architecture-neutral. A. Java B. C++ C. C D. Ada E. Pascal

A. Java

________ is interpreted. A. Java B. C++ C. C D. Ada E. Pascal

A. Java

Java compiler translates Java source code into _________. A. Java bytecode B. machine code C. assembly code D. another high-level language code

A. Java bytecode

________ 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

A. Java language specification

_________ is a software that interprets Java bytecode. A. Java virtual machine B. Java compiler C. Java debugger D. Java API

A. Java virtual machine

_____________ 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

A. Operating system

Java was developed by ____________. A. Sun Microsystems B. Microsoft C. Apple D. IBM E. Cisco Systems

A. Sun Microsystems

If you forget to put a closing quotation mark on a string, what kind of error will be raised? A. a compile error B. a runtime error C. a logic error

A. a compile error

Every statement in Java ends with ________. A. a semicolon (;) B. a comma (,) C. a period (.) D. an asterisk (*)

A. a semicolon (;)

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

A. java ByteCode

Computer can execute the code in ____________. A. machine language B. assembly language C. high-level language D. none of the above

A. machine language

Which of the following are the reserved words? A. public B. static C. void D. class

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

What is an interpreter? What is a compiler?

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 executes it right away. A compiler is a software that translates a program in high-level language into machine language code.

What programming language does Android use?

Android uses the Java programming language.

What is an assembly language? What is an assembler?

Assembly language is a low-level programming language in which a mnemonic is used to represent each of the machine language instructions. Assembler is a software that translates assembly language into machine language.

One byte has ________ bits. A. 4 B. 8 C. 12 D. 16

B. 8

___________ translates high-level language program into machine language program. A. An assembler B. A compiler C. CPU D. The operating system

B. A compiler

_ is the brain of a computer. A. Hardware B. CPU C. Memory D. Disk

B. CPU

__________ is the brain of a computer. A. Hardware B. CPU C. Memory D. Disk

B. CPU

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.

B. Every statement in a program must end with a semicolon.

________ contains predefined classes and interfaces for developing Java programs. A. Java language specification B. Java API C. Java JDK D. Java IDE

B. Java API

____________ are instructions to the computer. A. Hardware B. Software C. Programs D. Keyboards

B. Software C. Programs

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.println('Welcome to Java"); E. System.out.println("Welcome to Java');

B. System.out.println("Welcome to Java");

Due to security reasons, Java ___________ cannot run from a Web browser in the new version of Java. A. applications B. applets C. servlets D. Micro Edition programs

B. applets

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.

B. because digital devices have two stable states and it is natural to use one state for 0 and the other for 1.

A block is enclosed inside __________. A. parentheses B. braces C. brackets D. quotes

B. braces

Which of the following lines is not a Java comment? A. /** comments */ B. // comments C. -- comments D. /* comments */ E. ** comments **

C. -- comments E. ** comments **

The extension name of a Java bytecode file is A. .java B. .obj C. .class D. .exe

C. .class

________ is not an object-oriented programming language. A. Java B. C++ C. C D. C# E. Python

C. C

________ 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

C. Java JDK

____________ is an operating system. A. Java B. C++ C. Windows D. Visual Basic E. Ada

C. Windows

If a program compiles fine, but it produces incorrect result, then the program suffers __________. A. a compilation error B. a runtime error C. a logic error

C. a logic error

Programming style is important, because ______________. A. a program may not compile if it has a bad style B. good programming style can make a program run faster C. good programming style makes a program more readable D. good programming style helps reduce programming errors

C. good programming style makes a program more readable D. good programming style helps reduce programming errors

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

C. javac Test.java

The speed of the CPU may be measured in __________. A. megabytes B. gigabytes C. megahertz D. gigahertz

C. megahertz D. gigahertz

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)

C. public static void main(String[] args)

What does the acronym CPU stand for? What unit is used to measure CPU speed?

CPU stands for Central Processing Unit. It is the brain of the computer. The unit of measurement of clock speed is the hertz (Hz), with 1 hertz equaling 1 pulse per second. The clock speed of a computer is usually stated in megahertz (MHz) (1 MHz is 1 million Hz).

What is a comment? Is the comment ignored by the compiler? How do you denote a comment line and a comment paragraph?

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 Java, comments are preceded by two forward slashes (//) in a line or enclosed between /* and */ in multiple lines. When the compiler sees //, it ignores all text after // in the same line. When it sees /*, it scans for the next */ and ignores any text between /* and */.

Analyze the following code. I: public class Test { public static void main(String[] args) { System.out.println("Welcome to Java!"); } } II: public class Test { public static void main(String[] args) { System.out.println("Welcome to Java!"); } } A. Both I and II can compile and run and display Welcome to Java, but the code in II has a better style than I. B. Only the code in I can compile and run and display Welcome to Java. C. Only the code in II can compile and run and display Welcome to Java. D. Both I and II can compile and run and display Welcome to Java, but the code in I has a better style than II.

D. Both I and II can compile and run and display Welcome to Java, but the code in I has a better style than II.

Which of the following code has the best style? I: public class Test { public static void main(String[] args) { System.out.println("Welcome to Java!"); } } II: public class Test { public static void main(String[] args) { System.out.println("Welcome to Java!"); } } III: public class Test { public static void main(String[] args) { System.out.println("Welcome to Java!"); } } IV: public class Test { public static void main(String[] args) { System.out.println("Welcome to Java!"); } } A. I B. II C. III D. IV

D. IV

________ 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

D. Java IDE

____________ is a device to connect a computer to a local area network (LAN). A. Regular modem B. DSL C. Cable modem D. NIC

D. NIC

Suppose you define a Java class as follows, the source code should be stored in a file named _________. public class Test { } A. Test.class B. Test.doc C. Test.txt D. Test.java E. Any name with extension .java

D. Test.java

Which of the following is not permanent storage devices? A. floppy disk B. hard disk C. flash stick D. CD-ROM E. main memory

E. main memory

List five major hardware components of a computer.

Five major hardware components: CPU, Memory, Storage Devices, Input/Out Devices, and Communication Devices.

What does IDE stand for?

IDE stands integrated development environment.

What does JDK stand for? What does JRE stand for?

JDK stands for Java Development Toolkit. JRE stands for Java Runtime Environment.

What is the JVM?

JVM is the Java virtual machine that runs a Java program.

What is a Java applet?

Java applet is a special program that runs from a Web browser. Due to security reasons, applets are no longer allowed to run from Web browsers.

Can Java run on any machine? What is needed to run Java on a computer?

Java can run on any machine with a JVM.

If a NoClassDefFoundError occurs when you run a program, what is the cause of the error?

Java interpreter cannot find the .class file. Make sure you placed the file in the right place, and invoked java command with appropriate package name.

Is Java case sensitive? What is the case for Java keywords?

Java source code is case sensitive. Java keywords are always in lowercase.

Who invented Java? Which company owns Java now?

Java was invented by a team led by James Gosling at Sun Microsystems in 1991. Originally called Oak, it became Java in 1995 when it was redesigned for developing Internet applications. Oracle bought Sun and Oracle now owns Java.

What is a keyword? List some Java keywords.

Keywords have specific meaning to the compiler and cannot be used for other purposes in the program such as variables or method names. Examples of keywords are class, static, and void.

Identify and fix the errors in the following code: 1 public class Welcome { 2 public void Main(String[] args) { 3 System.out.println('Welcome to Java!'); 4 } 5 )

Line 2. Main should be main. Line 2. static is missing. Line 3: Welcome to Java! should be enclosed inside double quotation marks. Line 5: The last ) should be }.

Suppose you write a program for computing the perimeter of a rectangle and you mistakenly write your program so that it computes the area of a rectangle. What kind of error is this?

Logic error.

What are the major responsibilities of an operating system?

Major responsibilities: a. Controlling and monitoring system activities b. Allocating and assigning system resources c. Scheduling operations

What is memory for? What does RAM stand for? Why is memory called RAM?

Memory is like a work area for programs. Before a program is executed, it is brought into the memory. RAM stands for random-access memory. It is called RAM because a memory cell can be accessed directly.

What is the primary difference between memory and a storage device?

Memory 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.

What unit is used to measure memory size? What unit is used to measure disk size?

Memory size is measured in bytes. Disk size is measured in bytes.

What is multiprocessing?

Multiprocessing, or parallel processing, uses two or more processors together to perform a task.

What is multiprogramming?

Multiprogramming allows multiple programs to run simultaneously by sharing the CPU.

What is multithreading?

Multithreading allows concurrency within a program, so that its subtasks can run at the same time.

Are tools like NetBeans and Eclipse different languages from Java, or are they dialects or extensions of Java?

NetBeans and Eclipse are not programming languages, nor dialects, nor extensions of Java. They are Java development tools.

Show the output of the following code: public class Test { public static void main(String[] args) { System.out.println("3.5 * 4 / 2 - 2.5 is "); System.out.println(3.5 * 4 / 2 - 2.5); } }

Output is 3.5 * 4 / 2 - 2.5 is 4.5

If your program needs to read integers, but the user entered strings, an error would occur when running this program. What kind of error is this?

Runtime error.

If you forget to put a closing quotation mark on a string, what kind error will be raised?

Syntax error.

What are syntax errors (compile errors), runtime errors, and logic errors?

Syntax errors are detected by compilers. Runtime errors occur during execution of the program. Logic errors results in incorrect results.

What is the statement to display a string on the console?

System.out.println(string);

What is the Java language specification?

The Java language specification specifies the syntax for the Java language.

If a NoSuchMethodError occurs when you run a program, what is the cause of the error?

The class does not have a main method, or the signature of the main method is incorrect.

What is a high-level programming language? What is a source program?

The high-level languages are English-like and easy to learn and program. The program written in a programming language is called a source program.

What are the input and output of a Java compiler?

The input of a Java compiler is a Java source code file and the output is a Java class file.

What language does the CPU understand?

The machine language is a set of primitive instructions built into every computer. This is the language understood by a computer and executed by a computer.

What is an operating system? List some popular operating systems.

The operating system (OS) is a program that manages and controls a computer's activities. The examples of OS are Windows 98, NT, 2000, XP, or ME. Windows. Application programs such as an Internet browser and a word processor run on top of an operating system.

What is the Java source filename extension, and what is the Java bytecode filename extension?

The source file extension is .java and the bytecode file extension is .class.

What is the difference between an interpreted language and a compiled language?

What is the difference between an interpreted language and a compiled language? An interpreter reads one statement from the source code, and translates it to the machine code or virtual machine code, and then executes it right away. A compiler translates the entire source code into a machine code file, and the machine code file is then executed.

What is the command to run a Java program?

java is the JDK command to run a program.

What is the command to compile a Java program?

javac is the JDK command to compile a program.

Reformat the following program according to the programming style and documentation guidelines. Use the end-of-line brace style. public class Test { // Main method public static void main(String[] args) { /** Display output */ System.out.println("Welcome to Java"); } }

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


Set pelajaran terkait

Tableau Interview Questions-Data Visualization

View Set

N400 Nursing Concepts: Communication

View Set

January 20th- integumentary and intro to cartilage

View Set