Advertisement
STANAANDREY

exam poo

Jan 27th, 2024 (edited)
660
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1.  
  2. class A {
  3.     public void f(A a) {
  4.         System.out.println("f-A");
  5.     }
  6. }
  7.  
  8. class B extends A {
  9.     public void f(A o) {
  10.         System.out.println("f-B");
  11.     }
  12.     public void g() {
  13.         System.out.println("g");
  14.     }
  15. }
  16.  
  17. public class Main {
  18.  
  19.     public static void main(String[] args) {
  20.         A a = new B();
  21.         a.f(new B());
  22.         System.out.println(A.class.isInstance(new B()));
  23.     }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement