itai12345

Question

Jun 29th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. public class A {
  2.     public A() {
  3.         System.out.println("A1");
  4.     }
  5.     public A(int a) {
  6.         System.out.println(a);
  7.     }
  8.     public int foo(int a) {
  9.         return 0;
  10.     }
  11. }
  12. public class AA extends A {
  13.     public AA(int aa) {
  14.         System.out.println(aa);
  15.     }
  16. }
  17. public class B extends A {
  18.     public B(int b) {
  19.         super(b);
  20.     }
  21.     public int foo(Integer b) {
  22.         b = new Integer(b + 5);
  23.         return b;
  24.     }
  25.     public int foo(int b) {
  26.         return b;
  27.     }
  28. }
  29. public class C {
  30.     public static void main(String[] args) {
  31.         B b = new B(5);
  32.         A a = (A) b;
  33.         System.out.println(a.foo(2));
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment