JAVA认证历年真题:SCJP考试真题和解析(1)
来源:优易学  2011-9-22 19:41:05   【优易学:中国教育考试门户网】   资料下载   IT书店

19.Which declares for native method in a java class corrected?
A. public native void method(){}
B. public native void method();
C. public native method();
D. public void method(){native;}
E. public void native method();

19。B
native关键字指明是对本地方法的调用,在JAVA中是只能访问但不能写的方法,它的位置在访问权限修饰语的后面及返回值的前面。
20. Which modifer should be applied to a declaration of a class member variable for the value of variable to remain constant after the creation of the object?

20。final
定义常量的方法是在变量定义前加final关键字。
21. Which is the main() method return of a application?
A. String
B. byte
C. char
D. void


21。D
main()方法没有返回值,所以必须用void修饰。main()方法的返回值不能任意修改。
22. Which is corrected argument of main() method of application?
A. String args
B. String ar[]
C. Char args[][]
D. StringBuffer arg[]

22。B
main()方法的参数是字符串数组,参数名可以任意定义。
23. “The Employee object is a person, An Employee has appointment store in a vector, a hire date and a number of dependent”

short answer: use shortest statement declare a class of Employee.

23。public class Employee extends Person
这也是真实考试中常见的一种题型。要注意题目叙述中“is a”表示 “extends”的含义。

24. Give the following class defination inseparate source files:
public class Example{
public Example(){//do something}
protected Example(int i){//do something}
protected void method(){//do something}
}
public class Hello extends Example{//member method and member variable}
Which methods are corrected added to the class Hello?
A. public void Example(){}
B. public void method(){}
C. protected void method(){}
D. private void method(){}

24。A、B、C
考察的知识点是方法覆盖,其中要注意的是方法覆盖时,子类方法的访问权限不能小于父类方法的访问权限。另外,选项A并不是父类构造函数,它是子类中的新方法。
25. Float s=new Float(0.9F);
Float t=new Float(0.9F);
Double u=new Double(0.9);
Which expression?s result is true?
A. s==t
B. s.equals(t)
C. s==u
D. t.equals(u)
25。A、B
考察“==”及方法“equals()”的用法。注意以下几点区别:
1) 引用类型比较引用;基本类型比较值。
2) equals()方法只能比较引用类型,“==”可比较引用及基本类型。
3) 当用equals()方法进行比较时,对类File、String、Date及封装类(Wrapper Class)来说,是比较类型及内容。
4) 用“==”进行比较时,符号两边的数据类型必须一致(可相互转换的基本类型除外),否则编译出错。

上一页  [1] [2] [3] [4] [5] [6] [7] 

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训