Advertisement
Guest User

Untitled

a guest
Sep 15th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. // import java.lang.System;
  2.  
  3. class A {
  4.     public A() {
  5.         System.out.println("1");
  6.         m1();
  7.     }
  8.    
  9.     public A(int i) {
  10.         System.out.println("2");
  11.     }
  12.    
  13.     public A(A a) {
  14.         System.out.println("3");
  15.     }
  16.    
  17.     public void m1() {
  18.         System.out.println("4");
  19.     }
  20. }
  21.  
  22. class B extends A{
  23.     A a;
  24.    
  25.     public B(A a) {
  26.         System.out.println("5");
  27.     }
  28.    
  29.     public B() {
  30.         this(new A(0));
  31.         System.out.println("6");
  32.     }
  33.    
  34.     @Override
  35.     public void m1() {
  36.         System.out.println("7");
  37.     }
  38. }
  39.  
  40. public class Main {
  41.     public static void main(String[] args) {
  42.         A a = new B();
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement