Java OCA OCP Practice Question 1903

Question

Which of the following are valid declarations of the standard main() method?.

Select 2 options.

  • A. static void main (String args []) { }
  • B. public static int main (String args []) {}
  • C. public static void main (String args) { }
  • D. final static public void main (String [] arguments ) { }
  • E. public static void main (String [] args) { }


Correct Options are  : D E

Note

A valid declaration of the main() method must be 'public' and 'static', should return 'void', and should take a single array of Strings.

The order of the static and public keywords is irrelevant.

But return type should always come just before the method name.

'final' does not change the method signature.




PreviousNext

Related