Consider the following Java program:
class A { int x; int getX() { return x; } void setX(int x) { this.x = x; } void mA(int v) { x = v; } } class B extends A { int x, y; int getX() { return x; } void setX(int x) { this.x = x; } int getY() { return y; } void setY(int y) { this.y = y; } void mB(int v1, int v2) { x = v1; y = v2; } } class C extends B { int y; int getY() { return y; } void setY(int y) { this.y = y; } void mC(int v) { y = v; } } class Exercise { public static void main(String[] args) { A a = new A(); B b = new B(); C c = new C(); a.setX(1); b.setX(2); b.setY(3); c.setX(4); c.setY(5); a.mA(6); b.mA(7); c.mA(8); b.mB(9,10); c.mB(11,12); c.mC(13); System.out.println(a.getX()); System.out.println(b.getX()); System.out.println(b.getY()); System.out.println(c.getX()); System.out.println(c.getY()); } } |
What is the output of this program?