In Jaava, when declaring a class as a subclass of another class, the extends keyword is used. Here is an example:

class A {
    
    int value;
    
    void doSomething() {
        
    }
}

class B extends A {
    
}

In the above example, class B is a subclass of class A. In other words, class A is a super class of class B. As a sub class, class B inherits (extends) variables and methods declared from class A.

The extends keyword is also used to make an interface extends another interface, for example:

interface Animal { }

interface Reptile extends Animal { }

Related keyword: class, interface and implements. See all keywords in Java.

 

Related Topics:

 

Other Recommended Tutorials:


About the Author:

is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.



Add comment