a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 66|回复: 0

[考试试题] JAVA认证历年真题:SCJP考试真题和解析一(7)

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
19.Which declares for native method in a java class corrected?
' a+ D, [# _" U: mA. public native void method(){}
5 W8 m) G6 ?) i# ]8 GB. public native void method();
) ~3 ^( ?2 v0 m; [C. public native method(); / c! x3 Z9 {: z: N! f9 v& x" @
D. public void method(){native;} + `% z% L9 C: q* R+ y
E. public void native method();
3 G- N: _: }. \! \  19。B中 华 考 试 网2 ^1 Z% g" Z3 \1 f0 C$ c. w- K
native关键字指明是对本地方法的调用,在JAVA中是只能访问但不能写的方法,它的位置在访问权限修饰语的后面及返回值的前面。9 L. f: U$ S  H* G* L5 o
  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? + p7 G7 D! p) c: K
  20。final $ J  H, x0 J& |
定义常量的方法是在变量定义前加final关键字。" P0 @; k  x" z, V/ j0 y6 n
  21. Which is the main() method return of a application? - |( f/ ^; R9 p( `" @& b5 {2 @
A. String
8 q8 b: h2 H' M+ ]) E& c8 NB. byte 6 A9 G# L) _, N. C
C. char + q9 e, e* W& Z) C  P" ~9 b8 v
D. void $ r' ?8 j* J4 b9 l8 O4 h& A9 p" p" s& N
4 L7 I, j( P- t+ E5 Z3 w
  21。D
5 B3 Z0 f5 J$ e1 _' M! ymain()方法没有返回值,所以必须用void修饰。main()方法的返回值不能任意修改。
9 v* k  T5 s# b8 @( f  B( K  22. Which is corrected argument of main() method of application? & X( t$ k' y  ?( V5 ?* m- @
A. String args
0 m: a  _. j4 g/ g& k7 j$ \B. String ar[] 2 T2 q5 `, c* E* |6 u5 D
C. Char args[][]
. K9 @* i3 \+ _7 R; S3 i, {7 vD. StringBuffer arg[]
/ c6 g6 I7 ]. ?( L4 ]5 U8 y1 @$ l  22。B
- R4 P, v/ M$ ~8 Gmain()方法的参数是字符串数组,参数名可以任意定义。
+ j+ W: b8 z. [) V  23. “The Employee object is a person, An Employee has appointment store in a vector, a hire date and a number of dependent” - K0 V" T$ z0 ?  w2 Y3 r! F/ z
short answer: use shortest statement declare a class of Employee. ! t/ S7 s2 j. \5 \" p7 h
' M: m% q' L% t
  23。public class Employee extends Person
/ h! E6 W  D* ]7 B* A" C9 f这也是真实考试中常见的一种题型。要注意题目叙述中“is a”表示 “extends”的含义。
4 x' e5 c5 R5 p% Q; j  24. Give the following class defination inseparate source files:
7 d) v' b4 P" k4 H6 P* Opublic class Example{
; a: Q$ {  T" s( zpublic Example(){//do something} : ]7 y0 k8 S4 ]4 C7 h" K
protected Example(int i){//do something} 8 y& d+ g5 `/ o6 p9 a; h" X
protected void method(){//do something}
4 A5 ^+ w( E/ ~6 G6 p} 8 W3 J* [; W9 J1 z$ p6 g2 f
public class Hello extends Example{//member method and member variable}
4 }: ~' S4 |; Y- _5 O' A2 y( QWhich methods are corrected added to the class Hello? ! b  n* ^- ?( z0 j4 P% X9 v& p
A. public void Example(){}
% v: t6 o) T) n- ~& XB. public void method(){}
2 E3 U/ T, u1 R9 TC. protected void method(){} / O& u1 ^: L. c, h9 d: _
D. private void method(){}
+ W" B$ C; e7 F7 G7 D2 W3 V  24。A、B、C $ m* u( _( X0 Z5 q, ~7 S
考察的知识点是方法覆盖,其中要注意的是方法覆盖时,子类方法的访问权限不能小于父类方法的访问权限。另外,选项A并不是父类构造函数,它是子类中的新方法。+ z/ V& h5 F% X) f, v
  25. Float s=new Float(0.9F); , ]9 \+ K9 i  U3 I% S
Float t=new Float(0.9F);
# P/ o& V/ j- pDouble u=new Double(0.9);
1 y4 P, {1 ~5 y3 r3 |Which expression?s result is true?
1 [) R4 b& U- R! M+ A# [9 NA. s==t % L8 `. y* D9 \' U  Z
B. s.equals(t) 8 {5 J+ n3 [, s: d- D3 H9 T
C. s==u ; d8 a. B) r( k
D. t.equals(u) % K  B* b0 |. Q1 z/ V
  25。A、B
3 m0 ^6 K* x* S$ T2 p7 b  [8 N# b" N考察“==”及方法“equals()”的用法。注意以下几点区别: 2 x# e% F( T5 S+ s9 C  @' x
1) 引用类型比较引用;基本类型比较值。 % \. Z% U$ @$ o$ r  ^
2) equals()方法只能比较引用类型,“==”可比较引用及基本类型。
- k& A- U+ ?; Z$ G8 h1 J1 C3) 当用equals()方法进行比较时,对类File、String、Date及封装类(Wrapper Class)来说,是比较类型及内容。 5 L" C! I! E  s9 N8 R+ D$ h5 S
4) 用“==”进行比较时,符号两边的数据类型必须一致(可相互转换的基本类型除外),否则编译出错
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Woexam.Com ( 湘ICP备18023104号 )

GMT+8, 2024-5-15 16:12 , Processed in 0.246632 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表