Description:
Inheritance can be defined as the process where one class acquires the properties (methods and fields) of another.The extends is the keyword used to inherit the properties of a class.
Learn through my videos:

Program:
package inheritance;
public class Inheritance
 {
    public static void main(String[] args)
    {
        AddSub obj=new AddSub();
        obj.num1=5;
        obj.num2=4;
        obj.sum();
        System.out.println(obj.result);
        obj.sub();
        System.out.println(obj.result);             
          }
    }
class Add
{
    int num1,num2,result;
    public void sum()
    {
        result=num1+num2;
    }
}
class AddSub extends Add
{    
    public void sub()
    {
        result=num1-num2;
    }
}
Output:
9
1
Logic:
In single inheritance the subclass inherits the property of the super class .Only their is a single subclass which inherits the property of parent class.