With Complete Solutions
Graded A+
QUESTIONS AND ANSWERS
Which of the following declares a variable that will store a measurement with fractional
parts?
A) int measure;
B) double measure;
C) String measure;
D) integer measure; ANSWER -B) double measure;
Assuming that the user inputs "Joe" at the prompt, what is the output of the following code
snippet?
A) The code snippet does not compile because the += operator cannot be used in this
context
B) Joe, Good morning
C) , Good morning
D) Joe ANSWER -B) Joe, Good morning
The assignment operator
A) denotes mathematical equality
B) places a new value into a variable
C) means the same as the equal sign used in algebra
D) makes it illegal to write a statement like "sum = sum + 4" ANSWER -B) places a new
value into a variable
What term is used to refer a to a sequence of characters enclosed in quotation marks?
,A) string
B) object
C) comment
D) variable ANSWER -A) string
What is the result of the following statement
String s = "You" + "had" + "me" + "at" + "hello";
A) The string s has the following value: "You had me at hello"
B) The statement results in an error because the + operator can be only used with numbers
C) The statement results in an error because the + operator cannot be performed on string
literals
D) The string s has the following value: "Youhadmeathello" ANSWER -D) The string s
has the following value: "Youhadmeathello"
A method may be called by specifying which 3 items in the specified order? ANSWER -
Object, method name, parameters
When a Java application starts, what is the name of the method that is executed?
A) main
B) start
C) begin
D) Main ANSWER -A) main
What will be printed by the statement below
int x = 20;
int y = x;
x += 3;
y *= 2;
System.out.print("x = " + x + ", y = " + y);
, A) x = 23, y = 46
B) x = 23, y = 40
C) x = 46, y = 46
D) x = 3, y = 2 ANSWER -B) x = 23, y = 40
Assuming the following Java statement
Circle cl = new Circle (3);
What does the variable c1 store?
A) The constructed object itself
B) A reference to the circle class
C) A reference to the memory location of the constructed object
D) The numeric value 3 ANSWER -C) A reference to the memory location of the
constructed object
Assume a, b, and c have been defined to be integer variable. Which of the following value
makes the expression below true?
! (a == b) && (c > a)
A) a = 10, b = 10, c = 15
B) a = 10, b = 20, c = 15
C) a = 10, b = 2, c = 5
D) a = 10, b = 20, c = 10 ANSWER -B) a = 10, b = 20, c = 15
Parameters and local variables belongs to ________________ ANSWER -Methods
Instances variables belong to ________________ ANSWER -Objects
static variable belong to ________________ ANSWER -Classes