Java OCA OCP Practice Question 109

Question

What is the result of compiling and executing the following application?

package mypkg; 
public class MyClass { 
        private static boolean heatWave = true; 
        public static void main() { 
           boolean heatWave = false; 
           System.out.print(heatWave); 
        } 
} 
  • A. true
  • B. false
  • C. It does not compile.
  • D. It compiles but throws an error at runtime.


D.

Note

The application compiles without issue, Option C is incorrect.

The application does not execute, since the main() method does not have the correct method signature.

It is missing the required input argument, an array of String.

Trying to execute the application without a proper entry point produces an error.

Option D is the correct answer.




PreviousNext

Related