Java OCA OCP Practice Question 1678

Question

Which of these method declarations are valid declarations of the main() method that would be called by the JVM in order to start the execution of a Java application?.

Select the three correct answers.

(a)  static void main(String[] args) { /* ... */ }
(b)  public static int main(String[] args) { /* ... */ }
(c)  public static void main(String args) { /* ... */ }
(d)  final public static void main(String[] arguments) { /* ... */ }
(e)  public int main(Strings[] args, int argc) { /* ... */ }
(f)  static public void main(String args[]) { /* ... */ }
(g)  static public void main(String... args) { /* ... */ }


(d), (f), and (g)

Note

The main() method must be declared public, static, and void and takes a single array of String objects as argument.

The order of the static and public keywords is irrelevant.

Also, declaring the method final is irrelevant in this respect.




PreviousNext

Related