1 . A n a l yz e t h e f ol l ow i n g c o d e : p u b l i c c l as s
Te s t i m p l e m e nt s Ru n n a b l e { p u b l i c s t at i c vo i
d m a i n (S t r i n g[ ] a r gs ) { T h r e a d t = n e w T h r e a d
(t h i s ) ; t . s t ar t ( ) ; } p u b l i c vo i d r u n ( ) { S y
s t e m . o u t. p r i nt l n (“ t e s t ” ); } }
( a) T h e p ro g ra m d o e s n o t c om p i l e b e c au s e t h i s c an n o t b e re f e r e n c e d i n a s t a ti c m e t h o d .
( b ) T h e p ro g ra m c om p i l e s a nd r u n s fi n e an d d i s p l ay s te s t o n t h e c on s o l e . ( c ) R u nt i m e E r ro r ( d ) T h e p ro g ra m c om p i l e s fi n e , b u t i t d o e s n o t p r i nt any t h i n g b e c a u s e t d o e s n o t i nvo ke t h e ru n ( ) m e t h o d .
2 . S u p p o s e t h e r e ar e t h r e e Ru n n a b l e t a s k s , t as k 1 , t as k 2 , t as k 3 . H ow do yo u r u n t h e m i n a t h r e ad p o ol w i t h 2 fi xe d t h r e ad s ?
( a) E x e c u t o rS e rv i c e e xe c u to r = E x e c u t o rs . n e w F i x e d T h r e a d Po ol ( 1) ; e x e c u to r . e x e c u t e ( t as k 1 ) ; e xe c u - t or . e x e c u t e ( t a s k 2) ; e xe c u to r . e x e c u t e ( t as k3 ) ; ( b ) E x e c u t o rS e rv i c e e xe c u to r = E x e c u t o r s . n e w F i x e d T h r e a d Po ol ( 3) ; e x e c u to r . e x e c u t e ( t as k 1 ) ; e xe c u - t or . e x e c u t e ( t a s k 2) ; e xe c u to r . e x e c u t e ( t as k3 ) ;
( c ) E x e c u t o rS e rv i c e e xe c u to r = E x e c u t o r s . n e w F i x e d T h r e a d Po ol ( 2) ; e x e c u to r . e x e c u t e ( t as k 1 ) ; e xe c u - t or . e x e c u t e ( t a s k 2) ; e xe c u to r . e x e c u t e ( t as k3 ) ; ( d ) n e w T h r e ad ( t a s k 1) . s t a rt ( ) ; n e w T h r e a d (t a s k 2) . s t a rt ( ) ; n e w T h r e a d (t a s k 3) . s t a r t( ) ;
3 . W h i ch o f th e f o l l ow i n g i s n ot a c or r e c t s ta t e m e nt
( a) L o ck l o ck = n e w L o ck ( ); ( b ) L o ck l o ck = n e w R e e nt r ant L o ck ( f a l s e ) ; ( c ) L o ck l o ck = n e w R e e nt r ant L o ck ( t r u e ) ; ( d ) L o ck l o ck = n e w R e e nt r ant L o ck ( ) ;
4 . A n i n s t a n c e o f d e s c ri b e s s y s t e m e r r o rs . I f t h i s ty p e o f e r r or s o c c u rs , t h e r e i s l i t t l e you c a n d o b e yon d n o ti f yi n g t h e u s e r a n d t r y i ng t o t e r m i n a te t h e p r o gr a m g ra c e f u l l y.
( a) E x c e p t i o n ( b ) R u nt i m e E x c e p t i on ( c ) E r r or ( d ) T h r owa b l e
5 . W h a t e x c e p t i on ty p e d o e s th e f o l l ow i n g p r o gr a m t h row ? p u b l i c c l as s Te s t { p u b l i c s t at i c vo i d m a i n (S t r i n g[ ] ar g s ) { i nt [ ] l i s t = n e w i nt [ 5] ; S y s t e m . o u t. p r i nt l n (l i s t[ 5 ] ) ; } }
( a) A r i t h m e t i c E x c e p t i o n ( b ) S t r i n gI n d e x Ou t O f B o u n d s E x c e pt i o n
( c ) A r r ay I n d e x O u t O f B ou n d s E x c e p t i o n ( d ) C l a s s C as t E x c e p t i on
6 . W h i ch o f th e f o l l ow i n g i s n ot an a d va nt ag e o f J ava e x c e p ti o n h a n d l i n g?
( a) E x c e p t i o n h a n d l i n g i m p rove s p e r f o r m an c e . ( b ) J ava s e p a r at e s e x c e p t i on h an d l i n g f r o m n o r m al p r o c e s s i n g t as k s . ( c ) E x c e p t i o n h an d l i n g s i m p l i fi e s p r og r am m i n g b e c a u s e t h e e r r or - re p or t i n g a n d e r r or - h a n d l i n g c o d e c an b e p l a c e d a t t h e c a t ch b l o ck . ( d ) E x c e p t i o n h a n d l i n g m ake s i t p os s i b l e f or t h e c a l l e r’ s c a l l e r t o h a n d l e t h e e xc e p t i on .
7 . W h i ch o f th e f o l l ow i n g s t a t e m e nts r e g i s t e r s a p a n e l o b j e c t p a s a l i s t e n e r f o r a b u t t on va ri a b l e j b t?
( a) j b t . a d d A c t i on E ve nt Li s te n e r (p ) ; ( b ) j b t . a d d A c t i on L i s t e n e r ( p ) ; ( c ) a d d A c t i on L i s t e n e r ( p ) ; ( d ) j b t . a d d E ve nt L i s t e n e r ( p ) ;
8 . T h e i nte rf a c e s h o u l d b e i m p l e m e nt e d t o l i s t e n f or a b u tt o n a c t i on e ve nt . ( a) Fo c u s Li s te n e r ( b ) M o u s e L i s t e n e r ( c ) A c t i o n Li s te n e r ( d ) W i n d ow Li s te n e r
9 . W h i ch o f th e f o l l ow i n g p r o p e r ti e s a r e i n J A p p l e t ?
( a) c o nte nt Pa n e ( b ) t i t l e ( c ) r e s i z a b l e ( d ) i c o n I m a ge
1 0. W h i ch o f th e f o l l ow i n g p r o p e r ti e s i n j ava. aw t . C om p o n e nt m ay e ff e c t l ayou t ? ( a) b a ckg r ou n d ( b ) p r e f e r r e d S i z e ( c ) f o nt ( d ) f o r e gr o u n d
1 1. i s a S w i n g l ayou t m a n a ge r t h a t a rr a n ge s c o m p o n e nts o n t op of e a ch o th e r. ( a) G r i d L ayou t ( b ) B ox Layo u t ( c ) B o r d e r L ayou t ( d ) O ve r l ayL ayo u t
1 2. W h i ch o f th e f o l l ow i n g m e t h o d w i l l n ot c r e at e an E t ch e d B o r d e r ?
( a) B o r d e r Fa c t or y. c r e a t e E t ch e d B or d e r ( C ol o r . Y E L L OW , C ol o r . RE D ) ( b ) B o r d e r Fa c t or y. c r e a t e E t ch e d B or d e r ( )
( c ) n e w E t ch e d B o ar d e r ( ) ( d ) n e w E t ch e d B o r d e r (C ol o r . Y E L LOW , C o l o r. R E D )
1 3. H ow d o you di s p l ay a J Po p u p M e nu ?
( a) I nvoke t h e s h ow ( ) f ro m a J Po p u p M e nu .
( b ) I nvoke t h e s h ow ( C o m p o n e nt , x , y ) f r o m a J Po p u p M e nu . ( c ) I nvoke t h e s e t V i s i b l e ( t r u e ) f r o m a J Po p u pM e nu . ( d ) A d d t h e J Pop u p M e nu t o a c ont a i n e r.
1 4. W h i ch o f th e f o l l ow i n g s t a t e m e nt i s i n c or r e c t ?
( a) A J To ol B ar m ay b e fl oa t ab l e .
( b ) Yo u c an n o t ad d any G U I c om p o n e nt t o a J To o l B a r. ( c ) Y O u c a n s e t or i e nt at i o n o f a J To ol B ar . ( d ) A J To ol B ar i s a G U I c o m p o n e nt, s o i t c a n b e a d d e d t o a c o nt a i n e r .
1 5. W h i ch o f th e f o l l ow i n g s t a t e m e nt i s f al s e ?
( a) A c ont ai n e r s u ch a s J Fr am e i s a l s o a c o m p o n e nt.
( b ) A l l S w i n g G U I c om p o n e nt s a r e l i g htwe i g ht . ( c ) A u s e r i nt e r f ac e o b j e c t s u ch a s (b u t t on , l i s t ) c a n a p p e a r i n o n e c ont ai n e r . ( d ) To d is t i ng u i s h n e w S w i n g c om p o n e nt c l a s s e s f r om t h e i r AW T c ou nt e r p a rt s , S w i n g G U I c o m p o n e nt c l as s e s ar e n a m e d w i t h a p r e fi x J .
1 6. To s e t a F l ow L ayo u t i n p an e l j p , you c a n u s e t h e m e t h o d .
( a) j p . s e tL ayo u t (n e w F l ow Layo u t ( F l ow L ayou t . c e nt e r ) ) ;
( b ) j p . s e tL ayo u t (n e w F l ow Layo u t ( )) ; ( c ) j p . s e tL ayo u t (n e w F l ow Layo u t ( F l ow L ayou t ) ) ; ( d ) j p . s e tL ayo u t (F l ow L ayou t ( ) );
1 7. T h e m e t h o d s e t s t h e f o r e gr o u n d c o l o r t o ye l l ow i n J Fr am e f .
( a) s e t For e g r ou n d ( C o l or . Y E L L OW ) ( b ) f . s e tFor e G ro u n d ( C o l or . ye l l ow ) ( c ) s e t For e g r ou n d ( C o l or . ye l l ow )
( d ) f . s e tFor e g r ou n d ( C o l or . ye l l ow )
1 8. G i ve n a G r ap h i c s ob j e c t g, to d r aw a l i n e f r om t h e u p p e r l e f t c o rn e r t o th e b o tt o m r i g ht c or n e r , yo u u s e
( a) g . d raw L i n e ( 0, 0, 10 0, 10 0 ) ( b ) g . d raw L i n e ( 0, 0, ge t W i d t h ( ) , ge tW i d t h ( ) ) ( c ) g . d raw L i n e ( 0, 0, ge t H e i g ht () , ge t H e i g ht( ) )
( d ) g . d raw L i n e ( 0, 0, ge t W i d t h ( ) , ge tH e i ght ( ))
1 9. J C o mb oB ox fi r e s w h e n a n e w i t e m i s s e l e c t e d .
( a) j ava . aw t . A c t i on E ve nt ( b ) j ava x. s w i n g. e ve nt . A d j u s t m e nt E ve nt ( c ) j ava x. s w i n g. e ve nt . C h a n ge E ve nt ( d ) j ava . aw t . I t e m E ve nt
2 0. T h e c l i e nt r e q u e s t s a c on n e c t i on t o a s e rve r u s i n g th e f o l l ow i n g s t a t e m e nt:
( a) S o cke t s = n e w S o cke t( S e r ve r N am e , p o rt ) ; ( b ) S o cke t s = n e w S o cke t( S e r ve r N am e ) ; ( c ) S o cke t s = s e r ve r S o cke t. a c c e pt ( ) ; ( d ) S o cke t s = s e r ve r S o cke t. g e t S o cke t ( ) ;
A C A C C A B C A B D C B B B B D D A A
( a) T h e p ro g ra m d o e s n o t c om p i l e b e c au s e t h i s c an n o t b e re f e r e n c e d i n a s t a ti c m e t h o d .
( b ) T h e p ro g ra m c om p i l e s a nd r u n s fi n e an d d i s p l ay s te s t o n t h e c on s o l e . ( c ) R u nt i m e E r ro r ( d ) T h e p ro g ra m c om p i l e s fi n e , b u t i t d o e s n o t p r i nt any t h i n g b e c a u s e t d o e s n o t i nvo ke t h e ru n ( ) m e t h o d .
2 . S u p p o s e t h e r e ar e t h r e e Ru n n a b l e t a s k s , t as k 1 , t as k 2 , t as k 3 . H ow do yo u r u n t h e m i n a t h r e ad p o ol w i t h 2 fi xe d t h r e ad s ?
( a) E x e c u t o rS e rv i c e e xe c u to r = E x e c u t o rs . n e w F i x e d T h r e a d Po ol ( 1) ; e x e c u to r . e x e c u t e ( t as k 1 ) ; e xe c u - t or . e x e c u t e ( t a s k 2) ; e xe c u to r . e x e c u t e ( t as k3 ) ; ( b ) E x e c u t o rS e rv i c e e xe c u to r = E x e c u t o r s . n e w F i x e d T h r e a d Po ol ( 3) ; e x e c u to r . e x e c u t e ( t as k 1 ) ; e xe c u - t or . e x e c u t e ( t a s k 2) ; e xe c u to r . e x e c u t e ( t as k3 ) ;
( c ) E x e c u t o rS e rv i c e e xe c u to r = E x e c u t o r s . n e w F i x e d T h r e a d Po ol ( 2) ; e x e c u to r . e x e c u t e ( t as k 1 ) ; e xe c u - t or . e x e c u t e ( t a s k 2) ; e xe c u to r . e x e c u t e ( t as k3 ) ; ( d ) n e w T h r e ad ( t a s k 1) . s t a rt ( ) ; n e w T h r e a d (t a s k 2) . s t a rt ( ) ; n e w T h r e a d (t a s k 3) . s t a r t( ) ;
3 . W h i ch o f th e f o l l ow i n g i s n ot a c or r e c t s ta t e m e nt
( a) L o ck l o ck = n e w L o ck ( ); ( b ) L o ck l o ck = n e w R e e nt r ant L o ck ( f a l s e ) ; ( c ) L o ck l o ck = n e w R e e nt r ant L o ck ( t r u e ) ; ( d ) L o ck l o ck = n e w R e e nt r ant L o ck ( ) ;
4 . A n i n s t a n c e o f d e s c ri b e s s y s t e m e r r o rs . I f t h i s ty p e o f e r r or s o c c u rs , t h e r e i s l i t t l e you c a n d o b e yon d n o ti f yi n g t h e u s e r a n d t r y i ng t o t e r m i n a te t h e p r o gr a m g ra c e f u l l y.
( a) E x c e p t i o n ( b ) R u nt i m e E x c e p t i on ( c ) E r r or ( d ) T h r owa b l e
5 . W h a t e x c e p t i on ty p e d o e s th e f o l l ow i n g p r o gr a m t h row ? p u b l i c c l as s Te s t { p u b l i c s t at i c vo i d m a i n (S t r i n g[ ] ar g s ) { i nt [ ] l i s t = n e w i nt [ 5] ; S y s t e m . o u t. p r i nt l n (l i s t[ 5 ] ) ; } }
( a) A r i t h m e t i c E x c e p t i o n ( b ) S t r i n gI n d e x Ou t O f B o u n d s E x c e pt i o n
( c ) A r r ay I n d e x O u t O f B ou n d s E x c e p t i o n ( d ) C l a s s C as t E x c e p t i on
6 . W h i ch o f th e f o l l ow i n g i s n ot an a d va nt ag e o f J ava e x c e p ti o n h a n d l i n g?
( a) E x c e p t i o n h a n d l i n g i m p rove s p e r f o r m an c e . ( b ) J ava s e p a r at e s e x c e p t i on h an d l i n g f r o m n o r m al p r o c e s s i n g t as k s . ( c ) E x c e p t i o n h an d l i n g s i m p l i fi e s p r og r am m i n g b e c a u s e t h e e r r or - re p or t i n g a n d e r r or - h a n d l i n g c o d e c an b e p l a c e d a t t h e c a t ch b l o ck . ( d ) E x c e p t i o n h a n d l i n g m ake s i t p os s i b l e f or t h e c a l l e r’ s c a l l e r t o h a n d l e t h e e xc e p t i on .
7 . W h i ch o f th e f o l l ow i n g s t a t e m e nts r e g i s t e r s a p a n e l o b j e c t p a s a l i s t e n e r f o r a b u t t on va ri a b l e j b t?
( a) j b t . a d d A c t i on E ve nt Li s te n e r (p ) ; ( b ) j b t . a d d A c t i on L i s t e n e r ( p ) ; ( c ) a d d A c t i on L i s t e n e r ( p ) ; ( d ) j b t . a d d E ve nt L i s t e n e r ( p ) ;
8 . T h e i nte rf a c e s h o u l d b e i m p l e m e nt e d t o l i s t e n f or a b u tt o n a c t i on e ve nt . ( a) Fo c u s Li s te n e r ( b ) M o u s e L i s t e n e r ( c ) A c t i o n Li s te n e r ( d ) W i n d ow Li s te n e r
9 . W h i ch o f th e f o l l ow i n g p r o p e r ti e s a r e i n J A p p l e t ?
( a) c o nte nt Pa n e ( b ) t i t l e ( c ) r e s i z a b l e ( d ) i c o n I m a ge
1 0. W h i ch o f th e f o l l ow i n g p r o p e r ti e s i n j ava. aw t . C om p o n e nt m ay e ff e c t l ayou t ? ( a) b a ckg r ou n d ( b ) p r e f e r r e d S i z e ( c ) f o nt ( d ) f o r e gr o u n d
1 1. i s a S w i n g l ayou t m a n a ge r t h a t a rr a n ge s c o m p o n e nts o n t op of e a ch o th e r. ( a) G r i d L ayou t ( b ) B ox Layo u t ( c ) B o r d e r L ayou t ( d ) O ve r l ayL ayo u t
1 2. W h i ch o f th e f o l l ow i n g m e t h o d w i l l n ot c r e at e an E t ch e d B o r d e r ?
( a) B o r d e r Fa c t or y. c r e a t e E t ch e d B or d e r ( C ol o r . Y E L L OW , C ol o r . RE D ) ( b ) B o r d e r Fa c t or y. c r e a t e E t ch e d B or d e r ( )
( c ) n e w E t ch e d B o ar d e r ( ) ( d ) n e w E t ch e d B o r d e r (C ol o r . Y E L LOW , C o l o r. R E D )
1 3. H ow d o you di s p l ay a J Po p u p M e nu ?
( a) I nvoke t h e s h ow ( ) f ro m a J Po p u p M e nu .
( b ) I nvoke t h e s h ow ( C o m p o n e nt , x , y ) f r o m a J Po p u p M e nu . ( c ) I nvoke t h e s e t V i s i b l e ( t r u e ) f r o m a J Po p u pM e nu . ( d ) A d d t h e J Pop u p M e nu t o a c ont a i n e r.
1 4. W h i ch o f th e f o l l ow i n g s t a t e m e nt i s i n c or r e c t ?
( a) A J To ol B ar m ay b e fl oa t ab l e .
( b ) Yo u c an n o t ad d any G U I c om p o n e nt t o a J To o l B a r. ( c ) Y O u c a n s e t or i e nt at i o n o f a J To ol B ar . ( d ) A J To ol B ar i s a G U I c o m p o n e nt, s o i t c a n b e a d d e d t o a c o nt a i n e r .
1 5. W h i ch o f th e f o l l ow i n g s t a t e m e nt i s f al s e ?
( a) A c ont ai n e r s u ch a s J Fr am e i s a l s o a c o m p o n e nt.
( b ) A l l S w i n g G U I c om p o n e nt s a r e l i g htwe i g ht . ( c ) A u s e r i nt e r f ac e o b j e c t s u ch a s (b u t t on , l i s t ) c a n a p p e a r i n o n e c ont ai n e r . ( d ) To d is t i ng u i s h n e w S w i n g c om p o n e nt c l a s s e s f r om t h e i r AW T c ou nt e r p a rt s , S w i n g G U I c o m p o n e nt c l as s e s ar e n a m e d w i t h a p r e fi x J .
1 6. To s e t a F l ow L ayo u t i n p an e l j p , you c a n u s e t h e m e t h o d .
( a) j p . s e tL ayo u t (n e w F l ow Layo u t ( F l ow L ayou t . c e nt e r ) ) ;
( b ) j p . s e tL ayo u t (n e w F l ow Layo u t ( )) ; ( c ) j p . s e tL ayo u t (n e w F l ow Layo u t ( F l ow L ayou t ) ) ; ( d ) j p . s e tL ayo u t (F l ow L ayou t ( ) );
1 7. T h e m e t h o d s e t s t h e f o r e gr o u n d c o l o r t o ye l l ow i n J Fr am e f .
( a) s e t For e g r ou n d ( C o l or . Y E L L OW ) ( b ) f . s e tFor e G ro u n d ( C o l or . ye l l ow ) ( c ) s e t For e g r ou n d ( C o l or . ye l l ow )
( d ) f . s e tFor e g r ou n d ( C o l or . ye l l ow )
1 8. G i ve n a G r ap h i c s ob j e c t g, to d r aw a l i n e f r om t h e u p p e r l e f t c o rn e r t o th e b o tt o m r i g ht c or n e r , yo u u s e
( a) g . d raw L i n e ( 0, 0, 10 0, 10 0 ) ( b ) g . d raw L i n e ( 0, 0, ge t W i d t h ( ) , ge tW i d t h ( ) ) ( c ) g . d raw L i n e ( 0, 0, ge t H e i g ht () , ge t H e i g ht( ) )
( d ) g . d raw L i n e ( 0, 0, ge t W i d t h ( ) , ge tH e i ght ( ))
1 9. J C o mb oB ox fi r e s w h e n a n e w i t e m i s s e l e c t e d .
( a) j ava . aw t . A c t i on E ve nt ( b ) j ava x. s w i n g. e ve nt . A d j u s t m e nt E ve nt ( c ) j ava x. s w i n g. e ve nt . C h a n ge E ve nt ( d ) j ava . aw t . I t e m E ve nt
2 0. T h e c l i e nt r e q u e s t s a c on n e c t i on t o a s e rve r u s i n g th e f o l l ow i n g s t a t e m e nt:
( a) S o cke t s = n e w S o cke t( S e r ve r N am e , p o rt ) ; ( b ) S o cke t s = n e w S o cke t( S e r ve r N am e ) ; ( c ) S o cke t s = s e r ve r S o cke t. a c c e pt ( ) ; ( d ) S o cke t s = s e r ve r S o cke t. g e t S o cke t ( ) ;
A C A C C A B C A B D C B B B B D D A A
0 comments:
Post a Comment