Java OCA OCP Practice Question 174

Question

Which of the following lines contains a compiler error?

String title = "MyClass";                // line x1 
int hot, double cold;                    // line x2 
System.out.println(hot + " " + title);   // line x3 
  • A. x1
  • B. x2
  • C. x3
  • D. None of the above


B.

Note

Java does not allow multiple Java data types to be declared in the same declaration, making Option B the correct answer.

If double was removed, both hot and cold would be the same type.

Then the compiler error would be on x3 because of a reference to an uninitialized variable.




PreviousNext

Related