Java OCA OCP Practice Question 1511

Question

What will the following program print when compiled and run:

public class Main  { 
    public static void main (String [] args)  { 
            someMethod (); 
     } 
     
    static void someMethod (Object parameter)   { 
          System.out.println ("Value is "+parameter); 
     } 
} 

Select 1 option

  • A. It will not compile.
  • B. Value is null
  • C. Value is
  • D. It will throw a NullPointerException at run time.


Correct Option is  : A

Note

To call someMethod(Object parameter), you must pass exactly one parameter.

So someMethod() is not a valid call to this method and the code will not compile.

Note that parameter will not be assigned a null or default value.




PreviousNext

Related