Chapter 1 Test: Syntax/Output/Variables
Every method must have an open and close what?
brace
Never put a semicolon before an open what?
brace
What is the output by the code below? System.out.println(3+" "+3);
3 3
What is the output by the code below? System.out.print("ab\\ab");
ab\ab
What is the output of the code below? System.out.print("abc");
abc
What is the output by the code below? String s = "abcdef"; System.out.println(s);
abcdef
What is the output by the code below? public static void main (String args [] ) { }
nothing
What is the output by the code below? System.out.println(3+6);
9
What is the output by the code below? int x = 9; double y = x; System.out.println(y);
9.0
What is the ASCII value of 'b'?
98
In Java, every program statement ends with a what?
;
What is the output by the code below? char c = 65; System.out.println(c);
A
Which of the following types uses the most memory?
double
Which of the following lines correctly defines a double variable?
double d = 234.1;
Which of the following methods will move the cursor down to the next line?
println()
Which of the following can be used to comment code in Java?
//
What is the output by the code below? double y = 9.0; int x = y; System.out.println(x);
There is no output due to a syntax error.
Which of the following is a 32 bit data type?
int
Which of the following lines correctly defines an integer variable?
int i = 234;
What of the following is not a legal reserved word for a java data type?
integer
Which of the following is a valid identifier in Java?
java1234
Which of the following is the newline character?
\n
What is the output by the code below? System.out.println("\"9");
"9
What is the ASCII value of 'B'?
66
Which of the following lines correctly defines a String variable?
String s = "cdef";
Which of the following would print one backslash on the screen if used in a print( ) or println( )?
\\
Which of the following is the tab character?
\t
What is the output by the code below? System.out.print("a\tc");
a
Which of the following types uses the least memory?
char
Which of the following lines correctly defines a char variable?
char c = 'a';