Last active
February 13, 2021 04:24
-
-
Save karnzx/24cfd33e269aabafb90f31958fa3f368 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A { | |
private int x; | |
public A(int x) { | |
this.x = x; | |
System.out.println("A"); | |
} | |
public void foo() { | |
System.out.println(x); | |
} | |
} | |
class B extends A { | |
public B(int x) { | |
super(x); | |
System.out.println("B"); | |
} | |
} | |
public class Inherit01 { | |
public static void main(String[] args) { | |
new B(3).foo(); | |
System.out.println("6210110242"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment