nerdexam
Oracle

1Z0-809 · Question #114

Given: public class MainMethod { void main() { System.out.println("one"); } static void main(String args) { System.out.println("two"); } public static void main(String[] args) {…

The correct answer is C. three. C is correct because Java's JVM is hardwired to look for exactly one entry point signature: public static void main(String[] args) - it must be public (accessible by the JVM), static (callable without an instance), return void, and accept a String[] parameter. Option A fails on…

Question

Given: public class MainMethod { void main() { System.out.println("one"); } static void main(String args) { System.out.println("two"); } public static void main(String[] args) { System.out.println("three"); } void mina(Object[] args) { System.out.println("four"); } } What is printed out when the program is executed?

Options

  • Aone
  • Btwo
  • Cthree
  • Dfour

How the community answered

(40 responses)
  • A
    5% (2)
  • B
    8% (3)
  • C
    75% (30)
  • D
    13% (5)

Explanation

C is correct because Java's JVM is hardwired to look for exactly one entry point signature: public static void main(String[] args) - it must be public (accessible by the JVM), static (callable without an instance), return void, and accept a String[] parameter.

Option A fails on three counts: it's not public, not static, and takes no parameters - the JVM won't find it as an entry point. Option B is static but missing public, and critically takes a single String argument rather than a String[] array - an entirely different signature. Option D isn't even named main; it's named mina (a subtle typo trap), so the JVM never considers it regardless of its other characteristics.

Memory tip: Think of the acronym "PSV-S[]" - Public, Static, Void, String array []. If any one of those four elements is wrong, the JVM won't recognize it as the program entry point, even if other main-like methods exist in the same class.

Community Discussion

No community discussion yet for this question.

Full 1Z0-809 Practice