EXAM UPDATED ACTUAL Questions
and CORRECT Answers
Assuming that scan is a properly initialized Scanner variable, which of the following correctly
inputs a String? - CORRECT ANSWER - String val = scan.nextLine();
Consider the following code:
int x = -3;
x--;
System.out.println(x);
What is output? - CORRECT ANSWER - -4
Which of the following data types would be most appropriate to use when recording whether a
switch is in the "on" or "off" position? - CORRECT ANSWER - boolean
Which of the following is NOT a primitive data type? - CORRECT ANSWER - String
What is output by the following code?
int a = 91;
System.out.println(a / 2); - CORRECT ANSWER - 45
Which of the following is a legal variable name in Java? - CORRECT ANSWER - ans
What is (6 % 2) * 7? - CORRECT ANSWER -0