0% found this document useful (0 votes)
2 views6 pages

APCSA1 Fundamental Java CH 02 WSSummer 2022

Uploaded by

Yousef Hasan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views6 pages

APCSA1 Fundamental Java CH 02 WSSummer 2022

Uploaded by

Yousef Hasan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Fundamentals of Java Chapter 2: First Java Programs

UNIT 1—GETTING STARTED WITH JAVA


CHAPTER 2—FIRST JAVA PROGRAMS

EXERCISE 2.1

1. What is a portable program?

2. Describe two features of Java that make it a better language than C++.

3. What is a thread? Describe how threads might be used in a program.

EXERCISE 2.2

1. What does JVM stand for?

2. What is byte code? Describe how the JVM uses byte code.

1
Fundamentals of Java Chapter 2: First Java Programs

3. What is an applet? Describe how applets are used.

EXERCISE 2.4

1. Give a short definition of “program”.

2. What is the effect of the message println?

3. Describe how to use the System.out object.

4. Write a sequence of statements to display your name, address, and phone number
in the terminal window.
Here is an example answer, which is entirely fictional:

2
Fundamentals of Java Chapter 2: First Java Programs

EXERCISE 2.5

1. Name the three steps in writing and running a program.

2. What are compile-time errors?

3. Find the compile-time errors in the following statements.


a. System.out.println(“Here is an error);
b. System.out.println(“Here is another error”;

4. Why is readability a desirable characteristic of a program?

EXERCISE 2.6

1. What is a variable in a program and how is it used?

3
Fundamentals of Java Chapter 2: First Java Programs

2. Describe the role of the assignment (=) operator in a program.

3. What is a Scanner object?

4. Explain the difference between a variable of type double and a variable of type
Scanner.

5. Describe the difference between print and println, and give an appropriate
example of the use of each.

REVIEW QUESTIONS
1. List three reasons why Java is an important programming language.

4
Fundamentals of Java Chapter 2: First Java Programs

2. What is byte code?

3. What is the JMV?

4. List two objects that are used for terminal input and output in Java programs.

5. Give examples of two compile-time errors.

6. What steps must be followed to run a Java program?

7. Why do programmers use program comments in their code?

8. What is the purpose of an import statement in the Java program?

5
Fundamentals of Java Chapter 2: First Java Programs

Fill in the Blank


1. Two user interface styles are __________________ and ________________

2. The message ________________ is used to output data to the terminal window

3. The message ________________ is used to input a number from the keyboard

4. A(n) ______________ names a place where data can be stored in a Java program

5. A(n) _______________________________ stores the value of the expression in


the variable

6. Programs manipulate objects by sending them ___________________

You might also like