66.7k views
1 vote
Analyzing the following code:

class Test
{ public static void main(String args[])
{ NClass nc = new NClass();
nc.t = nc.t++;
}
}
class Foo
{ int t;
private NClass()
{ }
}

The program has a compilation error because the NClass class has a private constructor.
The program does not compile because the parameter list of the main method is wrong.
The program compiles, but has a runtime error because t has no initial value.
The program compiles and runs fine.

User Gelatin
by
6.2k points

1 Answer

1 vote

Answer:

Class NClass doesn't exist, so it won't compile.

Step-by-step explanation:

Even if Foo would be renamed to NClass, the next problem would be the private constructor of NClass.

User Fawce
by
4.8k points