Java OCA OCP Practice Question 4

Question

Which of the following method signatures is a valid entry point in a Java?application?

A.   public void main(String[] args) 
B.   public static void main() 
C.   private static void start(String[] mydata) 
D.   public static final void main(String[] mydata) 


D.

Note

An entry point in a Java application consists of a main() method with a single String[] argument, return type of void, and modifiers public and static.

The name of the variable in the input argument does not matter.

Option A is missing the static modifier.

Option B is missing the String[] argument.

Option C has the wrong access modifier and method name.

Only Option D fulfills these requirements.

Note that the modifier final is optional and may be added to an entry point method.




PreviousNext

Related