Created
May 10, 2017 03:57
-
-
Save colm-mchugh/0f670d8ff2bd573582f92bbd95eda725 to your computer and use it in GitHub Desktop.
plemm questionnaire - java
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
package plemm; | |
import org.junit.Test; | |
public class PlemmTest { | |
static class A { | |
int x; | |
public A() { | |
x = 3; | |
} | |
public int f() { | |
return x; | |
} | |
public int g() { | |
return x + f(); | |
} | |
} | |
static class B extends A { | |
int x; | |
public B() { | |
x = 30; | |
} | |
public int f() { | |
return x; | |
} | |
} | |
static class C extends B { | |
int x; | |
public C() { | |
x = 300; | |
} | |
public int g() { | |
return x + f(); | |
} | |
} | |
@Test | |
public void testABC() { | |
A ainst = new C(); | |
System.out.println(ainst.x); | |
System.out.println(ainst.f()); | |
System.out.println(ainst.g()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment