Font size
WorksheetsJava Chapter 2 Review Questions
Total questions: 22
Worksheet time: 12mins
Every complete statement ends with a:
period
parenthesis
semicolon
ending brace
The following data
72
'A'
"Hello World"
2.8712
are all examples of:
variables
literals
strings
none of these
A group of statements, such as the contents of a class or a method, are enclosed in
braces {}
parentheses ()
brackets []
any of these will do
Which of the following are not valid assignment statements?
(include all that apply)
total = 9;
72 = amount;
profit = 129
letter = 'W';
Which of the following are not valid println statements?
(Indicate all that apply.)
System.out.println + "Hello World";
System.out.println("Have a nice day");
out.System.println(value);
println.out(Programming is great fun);
The negation operator is
unary
binary
ternary
none of these
This keyword is used to declare a named constant.
constant
namedConstant
final
concrete
These characters mark the beginning of a multi-line comment
//
/*
*/
/**
These characters mark the beginning of a single-line comment
//
/*
*/
/**
These characters mark the beginning of a documentation comment
//
/*
*/
/**
Which Scanner class method would you use to read a string as input?
nextString
nextLine
readString
getLine
Which Scanner class method would you use to read a double as input?
nextDouble
getDouble
readDouble
None of these; you cannot read a double with the Scanner class
If you use this keyword to declare a local variable, you do not have to specify the variable's data type.
var
type
auto
local
When Java converts a lower-ranked value to a higher-ranked type it is call a(n)
4-bit conversion
escalating conversion
widening conversion
narrowing conversion
This type of operator lets you manually convert a value, even if it means that a narrowing conversion will take place.
cast
binary
uploading
dot
A left brace in a Java program is always followed by a right brace later in the program.
True
False
A variable must be declared before it can be used.
True
False
Variable names may begin with a number
True
False
You cannot change the value of a variable whose declaration uses the final keyword
True
False
Comments that begin with // can be processed by javadoc
True
False
If one of an operator's operands is a double, and the other operand is an int, Java will automatically convert the value of the double to an int
True
False
If you use the var keyword to declare a variable, you cannot initialize the variable with a value
True
False
