2.2 Q1: End-of-line comments that should be ignored by the compiler are denoted using
a. Two forward slashes (// ).
b. Three forward slashes (/// ).
c. A slash and a star (/* ).
d. A slash and two stars (/** ).
2.2 Q2: Which of the following is not a valid Java identifier?
a. my Value
b. $_AAA1
c. width
d. m_x
2.2 Q3: Which of the following cannot cause a syntax error to be reported by the Java compiler?
a. Mismatched{}
b. Missing*/ in a comment that begins with/*
c. Missing;
d. An extra blank line.
2.2 Q4: Which of the following does not contain a syntax error?
a. System.out.println( ‘Hello world!’ ):
b. System.out.println( “Hello
world!” );
c. System.out.println( “Hello world!” );
d. System.out.println( Hello world! );
Compiling and Executing Your First Java Application
2.2 Q5: Which command compiles the Java source code fileWelcome.java?
a. cd Welcome.java
b. javac Welcome.java
c. java Welcome.java
d. compile Welcome.java
2.2 Q6: Which command executes the Java class fileWelcome.class?
a. javac Welcome.class
b. java Welcome.class
c. java Welcome
d. run Welcome.class
Section 2.3 Modifying Your First Java Program
Displaying a Single Line of Text with Multiple Statements
2.3 Q1: Which is the output of the following statements?
System.out.print( “Hello “);
System.out.println( “World” );
a. Hello World
b. HelloWorld
c. Hello
World
d. World
Hello
Displaying Multiple Lines of Text with a Single Statement
2.3 Q2: Which of the following is the escape character?
a. *
b.
c. n
d. “