// INHERIT12 class A { private int x=1; A(int x) {this.x = x;} public int getX() {return x;} } class B extends A { B(int x) { super(x); } // Which of the following will work? // Rem: method calls variable from class // in which the method is WRITTEN: // public int getX() { return x+1; } // public int getX() { return super.getX()+1; } } public class inherit12 { public static void main(String[] args) { System.out.println(new B(4).getX()); } } // output with comments in B: 4 // output without comments in B: 5