Select one:
a. p
b. Public
c. public
d. public23
e. PuBlIc_tWeNtY_3
Question 2
What does a Java compiler do?
Select one:
a. Runs Java programs
b. Translates byte code in ".class" files into machine language
c. Translates source code in ".class" files into machine language
d. Translates source code in ".java" files into Java byte code in ".class" files
e. Translates source code in ".java" files into machine language
Feedback
Your answer is incorrect.
The correct answer is: Translates source code in ".java" files into Java byte code in ".class" files
Question 3
Consider the following line of Java code.
System.out.println("Hello, World!");
The full line of code is which of the following?
Select one:
a. a class
b. a method (subroutine)
c. an object
d. a parameter
e. a statement
Question 4
Consider the following line of Java code.
System.out.println("Hello, World!");
Which one of the following does NOT describe '"Hello, World!"'?
Select one:
a. a declaration
b. an expression
, c. a literal
d. a parameter
e. a statement
Question 5
Consider the following line of Java code.
System.out.println("Hello, World!");
"System" is which of the following?
Select one:
a. a class
b. a method (subroutine)
c. an object
d. a parameter
e. a statement
6. Consider the following Java program:
1 public class HelloWorld {
2 // My first program!
3 public static void main(String[] args) {
4 System.out.println("Hello, World!");
5 }
6}
What is on line 1?
Select one:
a. a variable declaration
b. a statement
c. a method (subroutine) definition
d. a comment
e. a class definition
Feedback
Your answer is correct.
See Section 2.1 of Eck (2014).
The correct answers are: a variable declaration, a class definition
Question 2
Consider the following Java statements.
int x = 3;
x = x++;
Select one:
, a. 0
b. 3
c. 4
d. 5
e. The question is moot. The statements have a syntax error.
Question 3
Which of the following should be used to compare the contents of two String objects in Java?
Select one:
a. =
b. ==
c. cmp
d. equals
e. ?
Feedback
Your answer is incorrect.
"=" is for assignment. "==" compares the memory locations of String objects, not their contents. "cmp" is a
command from Python, not Java. "?" Is the conditional operator. Use "s1.equals(s2)" to compare the
contents of String "s1" and "s2". See Section 2.3.3 of Eck (2014).
The correct answer is: equals
Question 4
Which of the following is NOT a valid identifier in Java?
Select one:
a. p
b. Public
c. public
d. public23
e. PuBlIc_tWeNtY_3
Question 5
What does a Java compiler do?
Select one:
a. Runs Java programs
b. Translates byte code in ".class" files into machine language
c. Translates source code in ".class" files into machine language
d. Translates source code in ".java" files into Java byte code in ".class" files