What is the output of the following code?
class Test { public static Test(int x) { if (x < 0) { return; } System.out.println(x); } } public class Main { public static void main(String[] args) { new Test(1); new Test(2); new Test(11); } }
public static Test(int x) { Illegal modifier for the constructor in type Test; only public, protected & private are permitted
Constructors are used in the context of the creating a new object.
You cannot declare a constructor static.