Chapter 2 Introduction to Java Applications Q1
The format specifier ________ is a placeholder for an int value?
%d
Which of the following is the ESCAPE character?
\
Which of the following is NOT a Java PRIMITIVE type?
real
Which of the following is NOT an ARITHMETIC operator?
.
What is the value of result after the following Java statements execute? int a, b, c, d, result; a = 4; b = 12; c = 37; d = 51; result = d % a * c + a % b + a;
119
END-of-line COMMENTS that should be ignored by the compiler are denoted using
2 FORWARD slashes ( // ).
Each of the following is a RELATIONAL or equality operator except:
=!
Which of the following CANNOT cause a SYNTAX ERROR to be reported by the Java compiler?
An EXTRA blank line
All IMPORT declarations must be placed
BEFORE the CLASS declaration
Which is the output of the following statements? System.out.print( "Hello "); System.out.println( "World" );
Hello World
Which of the following is NOT a COMPILATION ERROR?
Placing a SEMICOLON at the end of the 1st line of an IF statement.
A(n) ________ enables a program to READ DATA from the USER
Scanner.
Which of the following statements will print a single line containing "hello there"?
System.out.print( "hello" ); System.out.println( " there" );
Which of the following statement displays Hello World?
System.out.printf( "%s %s", "Hello", "World" );
Which of the following does NOT contain a SYNTAX ERROR?
System.out.println( "Hello world!" )
Which of the following statements would display the phase "Java is fun"?
System.out.println( "hellois fun\rJava " );
Which of the following ESCAPE sequences represents a CARRIAGE return?
\r
What will be output after the following Java statements have been executed? int a, b, c, d; a = 4; b = 12; c = 37; d = 51; if ( a < b ) System.out.println( "a < b" ); if ( a > b ) System.out.println( "a > b" ); if ( d <= c ) System.out.println( "d <= c" ); if ( c != d ) System.out.println( "c != d" );
a < b c != d
When method "printf" requires MULTIPLE arguments, the arguments are separated with ________.
commas (,).
Which of the following statements does NOT ALTER a memory location?
int a
Which of the following is a VARIABLE DECLARATION statement?
int total
Which command EXECUTES the Java class file Welcome.class?
java Welcome
Which command COMPILES the Java SOURCE CODE file Welcome.java?
javac Welcome.java
Which of the following is not a VALID Java IDENTIFIER?
my Value (Identifiers may not contain blanks).