Java SE 11: Programming Complete Quiz Questions and Answers

Answer :
  • nothing - this will not compile.

Explanation :

The int type in Java can be used to represent any whole number from -2147483648 to 2147483647. Therefore this code will not compile as the number assigned to 'a' is larger than the int type can hold.
Answer :
  • public TheClass() { x = 77; }

Explanation :

final class members are allowed to be assigned only in two places: declaration and constructor
Answer :
  • "123 "

Explanation :

The answer is "123 ". The abs() method evaluates to the one inside mypackage.Math class.
Answer :
  • It will not compile because of line 10.

Explanation :

Non-static method message() cannot be referenced from a static context.
Answer :
  • Iterator it = theList.iterator(); for (it.hasNext()) { System.out.println(it.next()); }

Explanation :

for (it.hasNext()) should be while (it.hasNext()).
Answer :
  • It will print "Hello World! " three times
Answer :
  • 10