class A {
private static int counter;
public static int getCounter(){return counter++;}
private static int innerCounter;
public static int getInnerCounter(){return innerCounter++;}
private
String name;
A() {name = "A" + getCounter();}
class B {
private String name;
B() {
name = "B" + getInnerCounter();
System.out.print(A.this.name + name); // 1
}}
static void m1() {new A().new B();} // 2
static void m2() {this.new B();} // 3
static void m3() {new B();} // 4
public static void main(String[] args) {
m1(); m2(); m3();
}}
What are the results of attempting to compile and run the program?
a. Prints: A0B0A1B1A1B2
b. Prints: A0B0A1B1A2B2
c. Prints: A1B0A0B1A0B2
d. Compile-time error at line 1
e. Compile-time error at line 2
f. Compile-time error at line 3
g. Compile-time error at line 4
answer:: a
i have a query why does 3 compile wat is 'this' in 3 since method is static