SHARE
TWEET

Untitled

a guest Jun 20th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class A1 {
  8.     int foo() {
  9.         return 1;
  10.     }
  11.  
  12.     int res1() {
  13.         return this.foo();
  14.     }
  15. }
  16.  
  17. class A2 extends A1 {
  18.     @Override
  19.     int foo() {
  20.         return 2;
  21.     }
  22.  
  23. }
  24.  
  25. class A3 extends A2 {
  26.     int res2() {
  27.         return this.res1();
  28.     }
  29.  
  30.     int res3() {
  31.         return super.foo();
  32.     }
  33.     @Override
  34.     int foo(){
  35.         return 3;
  36.     }
  37. }
  38.  
  39. class A4 extends A3 {
  40.     @Override
  41.     int foo() {
  42.         return 4;
  43.     }
  44. }
  45.  
  46. /* Name of the class has to be "Main" only if the class is public. */
  47. public class Main {
  48.     public static void main(String[] args) throws java.lang.Exception {
  49.         A1 a1 = new A1();
  50.  
  51.         A2 a2 = new A2();
  52.         A3 a3 = new A3();
  53.         A4 a4 = new A4();
  54.         System.out.println(a4.res3());
  55.     }
  56. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top