方法的是:()。
A.public Product(){}
B.public Product(String name){} C.public void Product(){}
D.public void Product(String name){}
28.下列代码的运行结果是( ) public class Test{ private int num;
private static Test test; public Test(int num){ this.num = ++ num; }
static{
int num = 16;
test = new Test(num); ++ test.num; }
public static void main(String[] args){ test = new Test(13);
System.out.println(test.num); } } A. 14 B. 15 C. 16 D. 17
29. (多选题)请看下列代码: public class Tetromino {
protected int move(int x) { return 0; } }
class T extends Tetromino { <插入代码> }
在<插入代码>处填入选项中的代码,使T类没有编译错误的是: A.public int move(int x) { return 0; }
。()
B.private int move(int x) { return 0; } C.private int move(long x) { return 0; } D.protected long move(int x) { return 0; }
30.仔细分析下列代码,请指出错误的行( )。 public class SomeThing{ private String str;
public int addOne(final int x){ return ++x; } }
A.public class SomeThing B.private String str;
C.public int addOne(final int x) D.return ++x;
31.(多选题)下列关于JVM的内存结构描述正确的是: A.类的各种信息在堆中保存
B.栈用于存放程序运行过程当中所有的局部变量 C.堆一般用于存储使用new关键字创建的对象 D.类是JVM的内存结构
32.下列代码的运行结果是( )
public static void main(String[] args){ String str = \ str += 42;
System.out.print(str); }
A. 42 B. 420 C. 462 D. 42042
33. (多选题)请看下列代码: public class Foo {
static void alpha() { /* more code here */}
。()
void beta() { /* more code here */} }
下列说法正确的是:()。
A.Foo.beta()是调用beta方法的正确方式 B.Foo.alpha()是调用alpha方法的正确方式 C.beta方法可以直接调用alpha方法 D.alpha方法可以直接调用beta方法
34.查看如下代码: public class Foo {
public void method(String str,int age){} }
下列选项中,和 Foo 类中 method 方法重载的方法是()。 A. public int method(String str,int age){} B. public void method(int year,String s){} C. public int method(int year,String s){} D. public int method(String str){}
35.下列代码的输出结果是:()。 public class StaticFoo { int num; static int x;
public static void main(String[] args) { StaticFoo foo1 = new StaticFoo (); foo1.num++; foo1.x++;
StaticFoo foo2 = new StaticFoo (); foo2.num++; foo2.x++;
StaticFoo foo3 = new StaticFoo (); foo3.num++; foo3.x++;
StaticFoo.x++;
System.out.print(foo3.num+\ System.out.println(foo3.x); } }
A.3,3 B.1,3 C.3,4 D.1,4
36. 下面关于interface,叙述错误的是:( ) A.一个interface可以继承多个interface B.接口中的方法可以由private修饰
C.interface中可以定义static final 常量 D.interface中可以无任何方法定义
37.下列代码的输出结果是: ( )。 public class A { public void info(){
System.out.println(\ } }
public class B extends A{ public void info(){
System.out.println(\ }
public static void main(String[] args) { A a=new B(); a.info(); } } A. B info
相关推荐: