题目内容

在下列方法定义中,方法头不正确的是()。

A. public int method( ){...}
B. public static int method(double y){...}
C. void method(double d){...}
D. public static method(double a){...}

查看答案
更多问题

()是作为void getSort(int x)方法的重载方法。

A. public getSort(float x)
B. int getSort(int y)
C. double getSort(int x, int y)
D. void get(int x, int y)

()不能作为void sort(int x)方法的重载方法。

A. public float sort(float x)
B. int sort(int y)
C. double sort(int x, int y)
D. void sort(double y)

为了区分重载方法,要求()。

A. 采用不同的形式参数列表
B. 返回值类型不同
C. 调用时用类名或对象名做前缀
D. 参数名不同

写出程序的运行结果: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 );}}

答案查题题库