Advertisement
zoro-10

Pr2a.java

Mar 30th, 2024 (edited)
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.32 KB | None | 0 0
  1. class A {
  2.  
  3.   void show() {
  4.     System.out.println("Base Class");
  5.   }
  6. }
  7.  
  8. class B extends A {
  9.  
  10.   @Override
  11.   void show() {
  12.     System.out.println("Derived Class");
  13.   }
  14. }
  15.  
  16. class Pr2a {
  17.  
  18.   public static void main(String args[]) {
  19.     A obj = new A();
  20.     obj.show();
  21.     B obj1 = new B();
  22.     obj1.show();
  23.   }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement