Multiple choice technology programming languages

package simplejava;public class TestConstructor{ int p ; public void TestConstructor(int p) { this.p=p; } public static void main(String[] args) { TestConstructor tp = new TestConstructor(10); TestConstructor tp = new TestConstructor(); System.out.println("p = "+tp.p); }}

  1. Compiler Error

  2. Exception

  3. p = 0

  4. p = 10

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

The method TestConstructor has a void return type, making it a regular method instead of a constructor. Since no valid constructor is defined, Java will provide a default no-arg constructor. However, the code attempts to call TestConstructor(10) which doesn't exist as a constructor.