类 MyClass 中有下列方法定义: public void testParams(params int[] arr) { Console.Write (使
已帮助 人
类 MyClass 中有下列方法定义: public void testParams(params int[] arr) { Console.Write ("使用 Params 参数!"); } public void testParams(int x,int y) { Console.Write ("使用两个整型参数!"); } 请问上述方法重载有无二义性?若没有,则下列语句的输出为()。 MyClass x = new MyClass(); x.testParams(0); x.testParams(0,1); x.testParams(0,1,2);
A.有语义二义性;
B.使用 Params 参数!使用两个整型参数!使用 Params 参数!
C.使用 Params 参数!使用 Params 参数!使用 Params 参数!
D.使用 Params 参数!使用两个整型参数!使用两个整型参数!
![类 MyClass 中有下列方法定义: public void testParams(params int[] arr) { Console.Write (使](/uploads/allimg/6-2848482Q9.jpg)
回答
共1条回复-
B 解析:本题考核构造函数和析构函数。题中定义了类MyClass的对象a,对象数据b,所以调用了构造函数3次,输出111。然后定义了对象指针*p[2],由于指针没有实例话,所以不会调用构造函数。
