Java认证模考试题(一)

文章作者 100test 发表时间 2007:03:14 17:03:22
来源 100Test.Com百考试题网


Java 2 TEST


Question: 1


Given the following code:

class Test{

private int m.

public static void fun() {

// some code...

}

}

How can the member variable m be accessible directly in the method fun()?


A. change private int m to protected int m

B. change private int m to public int m

C. change private int m to static int m

D. change private int m to int m

Explanation:


If the variable m is changed to be a static variable it can be accessible in the method fun() for this method is a static member method.

Correct Answer: C 1 of 60

 

Question: 2


Which methods are correct overloading methods of the following method:

public void example(){...}


A. public void example( int m){...}

B. public int example(){...}

C. public void example2(){...}

D. public int example ( int m, float f){...}

Explanation:


The overloading methods must have the same names. If only the return type of the methods are different it is sufficient tell the methods from each other. The arguments of the methods must be different enough to determine which method to call.

Correct Answer: A,D 2 of 60

 

Question: 3

中国公务2004-5-27 22:14:08
Given the following fragment of code:

public class Base{

int w, x, y ,z.

public Base(int a,int b){

x=a. y=b.

}

public Base(int a, int b, int c, int d){

// assignment x=a, y=b

w=d.

z=c.

}

}

Which expressions can be used at the point of // assignment x=a, y=b?


A. Base(a,b).

B. x=a, y=b.

C. x=a. y=b.

D. this(a,b).

Explanation:


In the second constructor, the call this(a,b) passes control the version of the constructor that takes two int arguments.

Correct Answer: C,D 3 of 60



相关文章


Sun认证Java程序员5.0升级版本
Java源代码案例--骑士巡游问题
JAVA基础:JAVA程序中实现FTP的功能
JAVA模拟题:TestoftheJavaSkill(2)
Java认证模考试题(一)
64位环境中的Java(下)
64位环境中的Java(上)
JAVA教程:解析Java的多线程机制
JAVA模拟题:TestoftheJavaSkill(1)
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛