Jtest.doc


文档分类:外语学习 | 页数:约28页 举报非法文档有奖
1/28
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/28
文档列表 文档介绍
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

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


Question: 4

Given the following definition:
String s = "story";
Which of the following expressions are legal?
A. s += "books";
B. char c = s[1];
C. int len = ;
D. String t = ();
Explanation:

Answer B is not correct for String is a class and can'T be treated as an array of char. Answer C is not

Jtest 来自淘豆网www.taodocs.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数28
  • 收藏数0 收藏
  • 顶次数0
  • 上传人mh900965
  • 文件大小113 KB
  • 时间2018-06-28