写出程序的运行结果:public class A{protected void test(float x){System.out.println("test(float):" + x);}protected void test(Object obj){System.out.println("test(Object):" + obj );}protected void test(String str){System.out.println("test(String):" + str );}public static void main(String[] args){A a1 = new A( );a1.test( "hello" );a1.test( 5 );}}
(1+X)关于 this 的描述,哪一个是错误的( )?
A. this 可以用于区分成员变量和局部变量。
B. this 可以用于调用其他构造方法。
C. 在同一个构造方法中,可以使用两次 this() 调用其他两个构造方法。
D. 在使用 this 调用其他构造方法时,要避免多个构造方法之间的无限循环现象。
(1+X)以下关于 this 和 super 的描述,哪一个是错误的( )?
A. this 和 super 都可以调用构造方法
B. this 可以调用当前类中的属性、方法
C. super 可以调用父类中的属性、方法
D. 可以在同一个构造方法中,同时使用 this 和 super 来调用其他的构造方法
给出以下不完整类:class Person{String name, department;int age;public Person(String n){ name = n;}public Person(String n, int a){ name = n; age = a;}public Person(String n, String d, int a){//给属性name、age赋值,比如: name = n; age = a;department = d;}}可取代注释部分位置内容达到注释的目标的是()。
A. Person(n, a);
B. this(Person(n, a));
C. this(n, a);
D. this(name,age);