Java Program using single inheritance


In this program, You will learn how to implement single inheritance in java.


class A { 
   //statement
}

class B extends A { 
   //statement
}

Example: How to implement single inheritance in java.

class A {
    int a = 10;
}

class Main extends A {

    void display() {
        System.out.println("The value of a is:" + a);
    }

    public static void main(String args[]) {
        Main obj = new Main();
        obj.display();
    }
}

Output:

The value of a is:10