下列代码编译和运行的结果是( )public class Wow {public static void go(short n) { System.out.println("short"); }public static void go(Short n) { System.out.println("SHORT"); }public static void go(Long n) { System.out.println(" LONG"); }public static void main(String[] args) {Short y = 6; int z = 7; go(y); go(z);}}
A. short LONG
B. SHORT LONG
C. 编译失败
D. 抛出运行时异常
查看答案
请看下列代码public class Foo {public void method(String str,int age){ }}和Foo类中method方法重载的方法是:
A. public int method(String str,int age){}
B. public void method(String s,int year){}
C. public void method(int year,String s){}
D. public int method(int year,String s){}
关于以下 application 的说明,正确的是( )1. class StaticStuff2. {3. static int x=10;4. static { x+=5;}5. public static void main(String args[ ])6. {7.System.out.println(“x=” + x);8. }9. static { x/=3;}10. }
A. 4 行与 9 行不能通过编译,因为缺少方法名和返回类型
B. 9 行不能通过编译,因为只能有一个静态初始化器
C. 编译通过,执行结果为:x=5
D. 编译通过,执行结果为:x=3
关于以下程序代码的说明正确的是():1.class HasStatic{2. private static int x=100;3. public static void main(String args[ ]){4. HasStatic hs1=new HasStatic( );5. hs1.x++;6. HasStatic hs2=new HasStatic( );7. hs2.x++;8. hs1=new HasStatic( );9. hs1.x++;10. HasStatic.x--;11. System.out.println(“x=”+x);12. }13.}
A. 5 行不能通过编译,因为引用了私有静态变量
B. 10 行不能通过编译,因为 x 是私有静态变量
C. 程序通过编译,输出结果为:x=103
D. 程序通过编译,输出结果为:x=102
下列哪种说法是正确的
A. 实例方法可直接调用超类的实例方法
B. 实例方法可直接调用超类的类方法
C. 实例方法可直接调用其他类的实例方法
D. 实例方法可直接调用本类的类方法