|
1. 下列Java源文件代码片段中, 是不正确的。
A. package t;public class A{}
B. import java.io.*;package t;public class A{}
C. import java.io.*;class A{}public class B{}
D. import java.io.*;import java.awt.*;public class A{}
正确资料:B 满分:4 分
2. Thread类的方法中,toString()方法的作用是
A. 只返回线程的名称
B. 返回当前线程所属的线程组的名称
C. 返回当前线程对象
D. 返回线程的字符串信息
正确资料:D 满分:4 分
3. 有数组定义:int a[]={0,1,2,3,4,5,6};,则a数组的数组元素个数为
A. a.length()
B. a.length()+1
C. a.length
D. a.length+1
正确资料:C 满分:4 分
4. 下列 修饰符可以使在一个类中定义的成员变量只能被同一包中的类访问。
A. private
B. public
C. protected
D. 无修饰符
正确资料:D 满分:4 分
5. Give incompleted method:
//one
{if(unsafe()){//do something...}
else if(safe()){//do the other...}
}
The method unsafe() will throw an IOException, which completes the method of declaration when added at line one?
A. public IOException methodName()
B. public void methodName()
C. public void methodName() throw IOException
D. public void methodName() throws IOException
正确资料:D 满分:4 分
6. 设有数组定义:int a[]=new int[8];,则a.length的值为
A. 0
B. 7
C. 8
D. 9
正确资料:C 满分:4 分
7. 下列 是Java的调试器,如果编译器返回程序代码的错误,可以用它对程序进行调试。
A. java.exe
B. javadoc.exe
C. jdb.exe
D. javaprof.exe
正确资料:C 满分:4 分
8. class A
{public int getNumber(int a){return a+1;}}
class B extends A
{public int getNumber(int a, char c){return a+2;}
public static void main(String[] args)
{B b=new B();System.out.println(b.getNumber(0));}
}
what is the result?
A. compilation succeeds and 1 is printed
B. compilation succeeds and 2 is printed
C. compilation succeeds and 3 is printed
D. An error at this program cause compilation to fail
正确资料:A 满分:4 分
9. 设有下面的两个类定义:class A{void show(){System.out.print("AA");}}
class B extends A{void show(){System.out.print("BB");}}
则顺序执行如下语句后输出的结果为 。A a=new A();B b=new B();
a.show();b.show();
A. AAAA
B. AABB
C. BBBB
D. BBAA
正确资料:B 满分:4 分
10. 有如下代码:class A{private int m;public static void f(){}}为了让f()方法能直接访问m,则应
A. 将private int m;改为protected int m;
B. 将private int m;改为public int m;
C. 将private int m;改为static int m;
D. 将private int m;改为int m;
正确资料:C 满分:4 分 |
|