waltermilner

Untitled

Jul 3rd, 2018
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.32 KB | None | 0 0
  1. public class Test { // example how to check for yourself
  2.  
  3.   public static void main(String args[]) {
  4.     A x = new B();
  5.     x.doIt(); // B version
  6.  
  7.   }
  8.  
  9. }
  10.  
  11. class A {
  12.  
  13.   void doIt() {
  14.     System.out.println("A version");
  15.   }
  16. }
  17.  
  18. class B extends A {
  19.  
  20.   void doIt() {
  21.     System.out.println("B version");
  22.   }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment