a = new StringBuffer(“A”);
StringBuffer b = new StringBuffer(“B”);
mb_operate(a, b);
System.out.println(a + “.” + b);
} // End of method: main
static void mb_operate(StringBuffer x, StringBuffer y){
x.append(y);
y=x;
} // End of method: mb_operate
} // End of class: J_StringBuffer
上面程序的输出是什么
A、A.B
B、A.A
C、AB.AB
D、AB.B
54.认真阅读下段例程,
1) class Super{
2) public float getNum(){return 3.0f;}
3) }
4)
5) public class Sub extends Super{
6)
7) }
下面语句,哪句放在第6行会引起编译错误?
A、public float getNum(){return 4.0f;}
B、public void getNum(){}
C、public void getNum(double d){}
D、public double getNum(float d){return 4.0d;}
55.在Q2_2类哪个是合法的覆盖(override)
public clsss Q2_1
{
public void method(int k){};
}
class Q2_2 extends Q2_1
{
}
A、public void method(int i){};
B、public void method(int j,int k){}
C、public float method(int k){};
D、private void method(int k){};
56.在Q2_2类中下面选项哪个没有形成合法的覆盖(override) (复选题)
public class Q2_1
{
protected void method(int k ,char c){};
}
class Q2_2 extends Q2_1
{
}
A、public void method(int i,char c){}
B、public void method(char c, long n){}
C、public float method(int k,char c){return 3.2F;}
D、protected void method(int k,char c){}
57.下面的类中,哪个不是合法的重载(overload)
public class Q1
{
public void method(int i){}
}
A、private void method(int i,int j){}
B、public void method(int k){}
C、private float method(float f){}
D、public String method(int i,int j){}
E、public float method(float f){}
58.看下面的代码,选择正确的结论:
class SuperClass
{
int i=8 ;
SuperClass()
{
add(1);
}
void add(int j)
{
i=i+j;
}
}
class SubClass extends SuperClass
{
int i=8;
void add(int j)
{
i=i+2*j;
}
}
public class MainClass
{
public static void main(String args[])
{
SuperClass a=new SubClass();
System.out.println(a.i);
}
}
A 、编译时出现错误 B、运行时出现错误
C、输出 10 D、输出 8
59.阅读以下例程,
int i=1,j=10;
do{
if(i++>–j) continue;
}while(i<5);
此段程序执行后,i和j的值是:
A、 i=6 j=5
B、 i=5 j=5
C、 i=6 j=4
D、 i=5 j=6
E、 i=6 j=6
60.对垃圾回收机制叙述正确的是:(复选题)
A、垃圾回收总是在程序结束时由虚拟机启动
B、一个对象在没有reference时会立即被回收
C、垃圾回收时机是没有保证的
D、程序员不能主动唤起垃圾回收
61.以下语句中有语法错误的是:
A、 for(;;;);
B、 for (int i=0;i<100;i++){};
C、 if (a<0) a++;
D、 ; ; ;
62.选择程序的标准输出结果
public class WhatIsX
{
public static void f(StringBuffer x)
{
x=x.append(x);
}
public static void main(String[] args)
{
StringBuffer x=new StringBuffer(“1″);
f(x);
System.out.println(x);
}
}
A、1
B、11
C、2
D、0
63.请问下面程序代码中,最后的a,b变量所存放的数值是什么?
int x,a=5,b=3;
x=a+++b–
A、x=8,a=5,b=3
B、x=8,a=6,b=2
C、x=7,a=5,b=2
D、x=9,a=6,b=3
64.下面程序代码运行完毕后,变量值会多少?
class A
{
public static void main(String args[])
{
int x=5;
switch(x)
{
case 5: x++;
System.out.println(x);
case 2+4:
System.out.println(x);
default:
x+=2;
System.out.println(x);
}
}
A、5
B、6
C、7
D、5,6
E、6,7
F、6,6
65.public class Test{
public static void main(String[] args){
String foo=args[1];
String bar=args[2];
String baz=args[3];
}
}
java Test Red Green Blue
baz的值是多少
A、baz has value of “”
B、baz has value of null
C、baz has value of “Red”
D、baz has value of “Blue”
E、baz has value of “Green”
F、the code does not compile
G、the program throw an exception
66. int index=1;
int foo[]=new int[3];
int bar=foo[index];
int baz=bar+index;
结果是多少
A、baz has a value of 0
B、baz has value of 1
C、baz has value of 2
D、an exception is thrown
E、the code will not compile
67.定义一个类名为“MyClass”的类,并且该类可被一个工程中的所有类访问,那么该类的正确声明应为:
A、private class MyClass extends Object
B、class MyClass extends Object
C、public class MyClass
D、private class MyClass extends Object
68.下面的哪段代码将不会出现编译错误?
A、int i = 0;
if(i){
System.out.println(“Hi”);
}
B、String a = “1″;
boolean b = true;
if( a = = b)
{
System.out.println(” so true”);
}
C、int i = 1;
i