Advertisement
tampurus

Constructor Inheritance

Mar 16th, 2022
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.39 KB | None | 0 0
  1. class Ramesh{
  2.     Ramesh(){
  3.         System.out.println("I'm from Ramesh Baap class");
  4.     }
  5. }
  6. class Suresh extends Ramesh{
  7.     Suresh(){
  8.         System.out.println("I'm from Suresh Bacha class");
  9.     }
  10. }
  11. public class Main{
  12.     public static void main(String[] args){
  13.         Suresh obj = new Suresh();
  14.     }
  15. }
  16.  
  17. /* Output:
  18. I'm from Ramesh Baap class
  19. I'm from Suresh Bacha class
  20. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement