10. Why would a responsible Java programmer want to use a nested class?1 s0 B8 K' o/ C& K
Don't know the answers. But here are some reasons from Exam Cram.
2 }* \# S* ]5 f$ N- X o: W. U- y6 T1 qA. To keep the code for a very specialized class in close association with the class it works with.
4 k0 k% E. S. U' m o% ]B. To support a new user interface that generates custom events.& Y6 D# U. L/ ?- S5 W. r! T4 G, z; Y
C. To impress the boss with his/her knowledge of Java by using nested classes all over the place.
% n# y t; ^( \AB. d9 O- @6 I5 E& s+ V; V8 H& V
11. You have the following code. Which numbers will cause "Test2" to be printed?
' s1 H7 g1 X8 S4 |7 q$ aswitch(x){
i* ?8 g2 B/ V$ j9 Q! pcase 1:7 S4 E( ^/ l8 c6 D9 Q, k1 a5 }7 N
System.out.println("Test1");
+ E# O& N0 W1 c. Y+ } Ccase 2:; J- H v. s( v' G. c2 O
case 3:
1 \5 C& W" X' ?5 JSystem.out.println("Test2");/ M* J$ |/ r* N" o) p8 u9 F* i
break;
- p8 X& w/ O4 ~( A% R# _0 z}
, a) }# Z! V4 D L$ eSystem.out.println("Test3");) R8 u8 @1 h$ i- `( a) S
}" b5 `9 G; l! a5 N7 ]" X8 J+ C4 N
A.0
9 l7 C; u! z" B; W3 @- J: NB.1
/ _5 l) O1 S# NC.23 ]8 N9 w- l; p$ x c5 j |. A
D.3+ J- U$ l7 k9 q6 R8 T i) l8 i9 B
E.4. \5 V- x+ F V8 I7 o
BCD.1 q: l$ U, D+ p7 F$ k0 ?1 d7 ^
12. Which statement declares a variable a which is suitable for referring to an array of 50 string objects?
3 P2 Z: v, b+ M+ J, M" L9 @& n& JA. char a[][];2 w. Z F& N- V& a; m
B. String a[];
( {1 L2 f9 L& W; b0 w0 GC. String []a;
8 c+ \: q) }: c3 e' h# u4 oD. Object a[50];
* x" K6 t' _; {5 H2 QE. String a[50];# y# x( r b I5 c! B6 U1 ]
F. Object a[];
' s/ E9 M% G) s: i6 B5 sBCF. |