About Question com.enthuware.ets.scjp.v6.2.272 :
Posted: Fri Mar 11, 2011 6:07 pm
The code for the question is -
For the output I chose the answer that "1 new thread is created by the program". Is that not so given that the main() thread is created?
Code: Select all
class MyClass implements Runnable
{
int n = 0;
public MyClass(int n){ this.n = n; }
public static void main(String[] args)
{
new MyClass(2).run();
new MyClass(1).run();
}
public void run()
{
for(int i=0; i<n; i++)
{
System.out.println("Hello World");
}
}
}