Question from the Java test

What happens when the following code is executed? public class Main { Main a=new Main(); public static void main(String[] args) { Main m=new Main(); m.printM(); } public void printM() { System.out.println("Yes!"); } }

Hard

What happens when the following code is executed?

public class Main
{
Main a=new Main();
public static void main(String[] args) {
Main m=new Main();
m.printM();
}
public void printM()
{
System.out.println("Yes!");
}
}

Author: FodiéStatus: PublishedQuestion passed 138 times
Edit
0
Community EvaluationsNo one has reviewed this question yet, be the first!