a我考网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 94|回复: 1

[考试试题] JAVA认证历年真题:310-025精选题(8)

[复制链接]
发表于 2012-8-4 12:33:16 | 显示全部楼层 |阅读模式
22. Which are correct class declarations? Assume in each case text constitutes the entire contents of a file called Fred.java on a system4 Q2 B0 V- E, g7 T6 K
with a case-significant system.
0 ]6 x6 }( S2 [" D1 GA. public class Fred {
" K& h# p! o3 w. a3 c$ q5 U. `public int x = 0;
* ]4 p0 Z/ [5 f2 L/ m9 npublic Fred (int x) {" b8 j# Z8 s$ r) S
this.x = x;. Z0 h1 S* r9 a/ h0 T& Z
}1 j, [9 D& F; ]3 C& d! B/ J& ]
}$ q3 y& T* {  y! c2 H* |- U
B. public class fred {% F1 K# t- h2 ?+ a5 G* b
public int x = 0;+ k  r( U% ^$ L& ^
public fred (int x) {
; _( p2 ?5 i. C# Hthis.x = x;- s1 l4 d9 r; x3 Z
}# ~0 d; Y  _$ C3 y( g, v
}2 l, l7 i' h- A: p# h
C. public class Fred extends MyBaseClass, MyOtherBaseClass {4 q9 C+ B3 c! {
public int x = 0;
2 h8 `- e* p) G' Tpublic Fred (int xval) {# {, b5 |& f* D. H9 ?
x = xval;; v, ]& U' p8 }! l  W
}
: |, o. f7 w! k, p$ P, _' P8 p}0 R, }' e/ x0 Q/ p9 A$ Q
D. protected class Fred {2 y/ o3 U. s+ \& F0 y7 h/ v
private int x = 0;
( |8 F" ]' D2 Yprivate Fred (int xval) {6 X4 H$ u: W& w
x = xval;$ n% h8 X4 N, ]$ P
}( W# Z$ b0 F4 w- x' ~1 P2 w) K" n
}6 l! c0 B1 o6 c2 G! L8 r
E. import java.awt.*;
& W4 {; |1 F  j- U3 e, spublic class Fred extends Object {
" p6 W' ?) L  ]) o+ l6 z* V# jint x;$ e. w0 Q! l* x% F
private Fred (int xval) {
! {7 Z# h) q0 _8 tx = xval;  }" @: x3 v$ A4 {8 J& K0 s
}
! z9 T3 b& S) x# a: l- a$ \8 {( V}' Y1 z# C8 {1 q  |, @) B
AE.
5 O6 W9 C1 B) ~0 N& YB is wrong because of case-sensitivity. C is wrong because multiple inheritance is not supported in Java. D is wrong because a class can
. V- G: ]- v, M" K) gonly be public, abstract, final or default (with no access modifier).
回复

使用道具 举报

 楼主| 发表于 2012-8-4 12:33:17 | 显示全部楼层

JAVA认证历年真题:310-025精选题(8)

23. Which are correct class declarations? Assume in each case text constitutes the entire contents of a file called Test.java on a system  ?% m6 }/ p. h
with a case-significant system.0 e  H7 \/ H( M+ }& a1 ^  u
A. public class Test {6 w6 Y& N6 j1 A& \/ {9 A
public int x = 0;
: j& O$ E+ Y( `( B6 upublic Test (int x) {
: z$ z3 j, d: |% k& }# \1 @, Sthis.x = x;1 q) \( B$ D6 R, t3 c2 M* g
}
+ @1 S- n& ?& V" ]$ ~}5 O$ w3 i) G/ V, i- L
B. public class Test extends MyClass, MyOtherClass {2 H, c& U; a- a2 `; I
public int x = 0;
4 z( N: A7 x/ [4 ^, Upublic Test (int xval) {( h; _3 w2 W0 F( [; H" U6 r
x = xval;
! |" m9 R: h( u$ {) r}8 N' R. V5 h9 w& c' [  N
}& X8 M7 |& x& j; d) t7 O# j
C. import java.awt.*;
. i- h" s/ f+ g) N) bpublic class Test extends Object {- j* f& r, E3 Y( a1 L9 c0 w% L
int x;' Y' n6 a0 l, V( F, V8 O
private Test (int xval) {
; h4 z0 Q/ v2 Q$ l& C$ I; p8 Tx = xval;) E7 Z% J' x! [+ G7 U7 `# o; b
}9 Y2 h5 a( \$ f( Y
}
- K9 ^0 x4 G- f6 m8 {D. protected class Test {
2 j) H. W% z+ E3 Z5 Kprivate int x = 0;! h! E$ k- T4 m2 u2 G; M, {0 F
private Test (int xval) {4 M$ _# F" u0 S1 x3 T) O+ a
x = xval;
4 `7 O1 j2 A. D2 u& k! m}! q6 ]( Q4 }2 }2 ^
}
, H4 N5 O" n8 k/ ?& JAC.. s! ~. s1 m, S! E0 l% N
24. A class design requires that a particular member variable must be accesible for direct access by any subclasses of this class, . U6 g" d4 Z1 g: m" _2 R9 H
otherwise not by classes which are not members of the same package. What should be done to achieve this?8 a/ |, N4 t( E( G' J2 G$ E% ^
A. The variable should be marked public1 l2 S( q0 Q% k; m; l
B. The variable should be marked private. {& `/ ~) m! l% y6 U  q5 i
C. The variable should be marked protected; k0 o# S1 f# n  z! P  S- L
D. The variable should have no special access modifier
" M. K: E5 x4 ^E. The variable should be marked private and an accessor method provided
% k0 Z  O; K# BC.
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-19 06:30 , Processed in 0.374909 second(s), 23 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

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