package inheritance; public class Derived extends BaseClass { int x=1; int y=2; float z=3; public Derived(){} public int x() {return x;} public void method1() { System.out.println("Derived method1"); } /* Overrides method with different return type public int method1() { System.out.println("Derived method1"); return 1; } */ public void method2() { System.out.println("Derived method2"); } public void method3() { System.out.println(x); System.out.println(super.x); } public Derived method4() { return new Derived(); } }