java多态性测试

public class HelloWorld {

public static void main(String[] args) {

new parent().test(null);

new child1().test(null);

new child1().test("hello");

new child1().test((Object)null);

String[] s = "=".split("=");

System.out.println(s.length);

}

}

 

class parent{

public void test(Object obj){

System.out.println("parent.test");

}

}

 

class child1 extends parent{

public void test(String str){

System.out.println("child1.tset");

}

}

你可能感兴趣的:(java)