Java Program to Implement Single Inheritance

You are currently viewing Java Program to Implement Single Inheritance

Java program to implement single inheritance

// Java program to implement 
// single inheritance

class Base {
  void BaseMethod() {
    System.out.println("Base method called.");
  }
}

class Derived extends Base {
  void DerivedMethod() {
    System.out.println("Derived method called.");
  }
}

public class Main {
  public static void main(String[] args) {
    Derived obj = new Derived();
    obj.BaseMethod();
    obj.DerivedMethod();
  }
}

Output

Base method called.
Derived method called.

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply