Created
July 29, 2012 14:43
-
-
Save kamatama41/3199313 to your computer and use it in GitHub Desktop.
OrverrideConstructorTest
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 com.kamatama41.sandbox4j; | |
import org.junit.Test; | |
public class OrverrideConstructorTest { | |
@Test(expected=NullPointerException.class) | |
public void test_Aの初期化時にBのsomeMethodが呼ばれてぬるぽ発生() throws Exception { | |
new OrverrideConstructorTest().new B(); | |
} | |
class A { | |
A() { | |
System.out.println("Construntor of A"); | |
someMethod(); | |
} | |
void someMethod() { | |
System.out.println("Call someMethod of A"); | |
} | |
} | |
class B extends A { | |
C c; | |
B() { | |
System.out.println("Construntor of B"); | |
c = new C(); | |
} | |
@Override | |
void someMethod() { | |
System.out.println("Call someMethod of B"); | |
c.doSomething(); | |
} | |
} | |
class C { | |
void doSomething() { | |
System.out.println("test"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment