Multiple choice technology programming languages

package simplejava; public class TestMain { TestMain() { System.out.println("I am in Constructor"); } TestMain(String message) { System.out.println("Message " + message); } public static void main(String[] args) { TestMain tm = new TestMain(); } public static void main(String args) { TestMain tm = new TestMain("Hello"); } }

  1. Compiler Error

  2. I am in Constructor

  3. Message Hello

  4. Exception

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The code defines two main methods with different signatures: main(String[] args) and main(String arg). Java allows method overloading with different parameter lists. When the class is run, the JVM invokes main(String[] args), creating a TestMain object with the no-arg constructor, which prints 'I am in Constructor'.