Java class instance field Question 1

Question

What is the output of the following code?


public class Main {
  String name = "Java";
  public static void main(String[] args) {
    new Main();//w ww .j a va2  s .c om
  }
  Main() {
    String name = "Javascript";
    new YetAnotherClass(this);
  }
}
class YetAnotherClass {
  YetAnotherClass(Main whoCreatedMe) {
    String name = "Java 8";
    System.out.println(name);
    System.out.println(whoCreatedMe.name);
  }
}


Java 8
Java



PreviousNext

Related