Inheritance
In object-oriented programming (OOP), inheritance is a mechanism that allows a class to inherit the properties and methods from another class.
Inheritance sample code
package in.ihelpyou; class Calc { public int a, b; public int addition() { return a + b; } public int subtraction() { return a - b; } } class SciCalc extends Calc { public int x, y; public int square() { Calc obj = new Calc(); obj.a = x; obj.b = y; int c = obj.addition(); return c * c; } public static void main(String[] args) { SciCalc sciobj = new SciCalc(); sciobj.x = 5; sciobj.y = 2; int z = sciobj.square(); System.out.println("Square: " + z); } }