can this keyword be used in an abstract class in java
- by Reddy
I tried with below example, it is working fine.
I expected it to pick sub-class's value since object won't be created for super class (as it is abstract). But it is picking up super class's field value only.
Please help me understand what is the concepts behind this?
abstract class SuperAbstract {
private int a=2;
public void funA() {
System.out.println("In SuperAbstract: this.a "+a);
}
}
class SubClass extends SuperAbstract {
private int a=34;
}
I am calling new SubClass.funA();
I am expecting it to print 34, but it is printing 2.