Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.*;
- import java.lang.*;
- import java.io.*;
- class A1 {
- int foo() {
- return 1;
- }
- int res1() {
- return this.foo();
- }
- }
- class A2 extends A1 {
- @Override
- int foo() {
- return 2;
- }
- }
- class A3 extends A2 {
- int res2() {
- return this.res1();
- }
- int res3() {
- return super.foo();
- }
- @Override
- int foo(){
- return 3;
- }
- }
- class A4 extends A3 {
- @Override
- int foo() {
- return 4;
- }
- }
- /* Name of the class has to be "Main" only if the class is public. */
- public class Main {
- public static void main(String[] args) throws java.lang.Exception {
- A1 a1 = new A1();
- A2 a2 = new A2();
- A3 a3 = new A3();
- A4 a4 = new A4();
- System.out.println(a4.res3());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement