310-025精选题(42)的具体内容如下:
" _8 p% D) M# a4 o' t5 o190. Consider the following code: What will be printed?
7 e) b" m B: F1 r/ U# X1 ?public class ExceptionTest2{8 X- ^3 z6 F5 E0 y! E1 c* D5 r
public static void main(String[] args){
! _( j+ [7 M }1 ~; R3 [ExceptionTest2 e = new ExceptionTest2();
0 R4 R1 Z3 ?3 v3 K! i& J8 Fe.divide(4, 0);}
; w! u4 J! }$ e- \/ wpublic void divide(int a, int b){
, {+ Y, ]: u' h" B9 |6 {. ]try{
8 j/ {4 v p% T. B! A2 Cint c = a/b;
1 a/ |: e! Z! o7 n7 i}7 i( m w" S, A& Z) T, U2 }
catch(ArithmeticException e){
# v; V! w f; i2 gSystem.out.println("ArithmeticException");* K/ z+ P# _4 k2 v) [& W
}
: g# E, G, ?6 V% b, Ocatch(RuntimeException e){1 }' H" _" I, _- b% B6 d
System.out.println("RuntimeException");
( y1 @/ P9 z( ~}/ R! P" }. Z4 v+ X
catch(Exception e){
1 L+ a2 k- s' s% t+ O& F. F/ ESystem.out.println("Exception");
2 _( a0 V% m ~! N3 F7 ^' o& J}
% r6 S# h0 f0 Q: l) G) {: pfinally{& M4 K( q: }( K/ e$ Y1 U% q. ~
System.out.println("Finally");* G. [0 Z, \) A0 X6 d# t1 a2 M& Y
}
5 K7 m: M5 ~7 x0 m. X& r}8 E ~* `: @. b, c
} A. ArithmeticException: C5 E- s, j% ~
B. RuntimeException
6 r8 ]8 @% a$ b! M9 S& rC. Exception
( C3 m+ L) ^/ x. a. K, ^$ y5 E2 E# PD. Finally
8 u& [, R4 V! H5 u1 F; [ N' IA. ArithmeticException D. Finally.
" {) B# a/ E6 u7 |# l' J5 U! `# h- b6 ^" G, O" s4 a
191. Consider the following code: What will be printed?6 e5 p" |3 L$ }3 F6 H
public class ExceptionTestMindQ{
9 N% q; x, A# _4 P4 T5 q9 p M! u1 ]. cpublic static void main(String [] args){
; R; T7 x8 ?& L2 _1 ?0 e& tExceptionTestMindQ e = new ExceptionTestMindQ();$ s% ^4 Z( r' l9 y2 }' A
e.trythis();
. k D) F$ q# d* j, l2 B" R}
# B1 l% K1 Z8 k* J5 D2 U1 cpublic vo id trythis(){5 Y" ?0 j v/ L3 G: l+ C1 z
try{
3 Y; M. h0 ~# T9 VSystem.out.println("Innan testet");
b$ }. |! m' r0 p: a' D' g4 K2 x7 @problem();
x2 B v+ q; b7 |( Z* [} M1 @+ A' Z3 i3 M5 q/ L# `
catch (NullPointerException x){" ~' e+ f4 H% C1 g
System.out.println("Nullpointer");
0 L# r- F* n2 \9 w& |}; ?7 L4 L; A, E- L" |3 z
catch(Exception x){, H- g5 B: r' d; M
System.out.println("Exception"); |