Monday, April 16, 2012


1 . W h i ch o f th e f o l l ow i n g e x p r e s s i on s mu s t b e tr u e i f yo u c r e a te a t h r e ad u s i n g T h r e a d = n e w T h r e ad ( o b j e c t) ?
( a) o b j e c t i n s t an c e of A p p l e t ( b ) o b j e c t i n s t an c e of Ru n n a b l e ( c ) o b j e c t i n s t an c e of Fr a m e ( d ) o b j e c t i n s t an c e of T h r e a 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 ( 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 ) ; ( b ) 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( ) ; ( 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 ( 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 ) ; ( d ) 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 ) ;


3 . W h i ch m e th o d o n a c on d i t i on s h o u l d you i nvoke to wa ke a l l wa i ti n g t h r e a d s .
( a) c o n d i t i on . s i g n al ( ) ; ( b ) c o n d i t i on . s i g n al A l l ( ) ; ( c ) c o n d i t i on . wa ke A l l ( ) ; ( d ) c o n d i t i on . wa ke ( ) ;

4 . A J ava e x c e p ti o n i s an i n s t an c e o f .
( a) T h r owa b l e ( b ) R u nt i m e E x c e p t i on ( c ) E x c e p t i o n ( d ) E r r or

5 . A m e th o d mu s t d e c l a re t o t h row .
( a) R u nt i m e E x c e p t i on ( b ) u n ch e cke d e x c e p ti o n s
( c ) ch e cke d e x c e p ti o n s ( d ) E r r or

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 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 .
( 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 a n d l i n g i m p rove s p e r f o r m an c e .
( 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 i s n ot a c or r e c t a s s e rt i o n s t a t e m e nt?
( a) a s s e r t ( i < 1 0) ; ( b ) a s s e r t s u m > 1 0 && s u m < 5 * 1 0 : “s um i s ” + s u m ; ( c ) a s s e r t ( i > 1 0) ; ( d ) a s s e r t “ s u m i s ” + s u m ;


8 . To ge t th e x c o o rd i n a t e o f t h e m ou s e p o i nt e r f o r t h e M o u s e E ve nt e vt , yo u u s e .
( a) e v t . ge tX Y ( ) ( b ) E ve nt . ge t Po i nt ( x , y ) ( c ) e v t . ge tX ( ) ( d ) E ve nt . ge t Po i nt ( ) . x


9 . 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) To s t ar t a t i m e r , i nvoke t i m e r . s t a rt ( ) . ( b ) Yo u n e e d n o t al way s s p e c i f y a l i s te n e r w h e n c r e at i n g a T i m e r ob j e c t . ( c ) To s t op a ti m e r , i nvo ke t i m e r. s to p ( ) . ( d ) Yo u c an ad d mu l t i p l e l i s t e n e r s f or a T i m e r ob j e c t .

1 0. W h i ch o f th e f o l l ow i n g a r e t op - l e ve l c o nt ai n e r s (i . e . c a n n ot e e mb e d e d i n a n ot h e r c ont ai n e r) ?
( a) J A p p l e t ( b ) J Pa n e l ( c ) J D i al o g ( d ) J O p ti n Pa n e

1 1. W h i ch o f th e f o l l ow i n g a r e t h e i nval i d m e t h o d s i n J Tab b e d Pan e ?
( a) g e t Ta b b e d C o u nt( ) ( b ) g e t T i t l e At( i n d e x ) ( c ) g e t To o l T i p Te x t At (i n d e x) ( d ) g e t Ta b P l a c e m e nt ( )


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) n e w E t ch e d B o ar d e r ( ) ( 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 ol o r . Y E L L OW , C ol o r . RE D ) ( c ) 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 ) ( d ) 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 ( )

1 3. A J C h e ck B ox M e nu I te m i s n ot a s u b c l as s o f .
( a) J M e nu ( b ) J C o m p o n e nt ( c ) J M e nu I t e m ( d ) A b s t r ac tB u t to n

1 4. a s k s a q u e s t i o n a n d r e q u i r e s t h e u s e r t o r e s p o n d w i th an ap p r o p ri a t e b u t t on .
( a) A m e s s a ge d i al o g ( b ) A n o p t i on d i al o g ( c ) A n i n p u t d i al o g
( d ) A c on fi r m a ti o n d i a l og

1 5. W h i ch o f th e f o l l ow i n g c l a s s e s a r e n o t i n t h e j ava. aw t p ackag e ?
( a) J Fr a m e ( b ) C o l or ( c ) Fo nt ( d ) C o m p o n e nt

1 6. H ow m a ny f r am e s ar e d i s p l aye d ? i m p o r t j avax . s w i n g . * ; p u b l i c c l as s Te s t e xt e n d s J Fr a m 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[ ] ar g s ) { J Fr a m e f 1 = ne w Te s t ( ) ; J Fr a m e f 2 = ne w Te s t ( ) ; J Fr a m e f 3 = ne w Te s t ( ) ; f 1 . s e t V i s i b l e ( t r u e ) ; f 2 . s e t V i s i b l e ( t r u e ) ; f 3 . s e t V i s i b l e ( t r u e ) ; } }

( a) 2 . ( b ) 3 . ( c ) 0 . ( d ) 1 .

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) f . s e tFor e G ro u n d ( C o l or . ye l l ow )
( b ) f . s e tFor e g r ou 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 ) s e t For e g r ou n d ( C o l or . Y E L L OW )

1 8. 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) Yo u c an ob t ai n t h e l e a d i n g , as c e nt , d e s c e nt, an d h e i ght f or a f ont f r o m a Fo nt M e t r i c s o b j e c t
. ( b ) Yo u c an c r e at e a Fo nt M e tr i c u s i n g n e w Fo nt M e tr i c s () ( c ) Yo u c an ob t ai n a Fo ntM e t ri c s f r o m a Fo nt o b j e c t u s i n g t h e g e t Fo ntM e t ri c s ( ) m e t h o d . ( d ) A f ont d e t e r m i n e s t h e f o nt m e t r i c s .

1 9. T h e c o m p o n e nt f or s t o ri n g an d h a n d l i n g d a t a, k n ow n as , c o nt ai n s t h e a c t u al c o nte nt s o f t h e c o m p on e nt .
( a) a c o ntr o l l e r ( b ) a C o nta i n e r ( c ) a m o d e l ( d ) a v i e w

2 0. To c r e at e an I n p u t S tr e a m t o r e a d f r o m a fi l e o n a We b s e r ve r , yo u u s e t h e c l a s s . U R L;
( a) S e r ve r ; ( b ) S e r ve r S o cke t ; ( c ) U R L; ( d ) S e r ve r S tr e a m ;


BABAC CDCBC AAADA BBBCC
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
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) R u nt i m e E r ro r
( b ) 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 .
( c ) 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 .
( 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 . W h e n yo u r u n t h e f ol l ow i n g p r og r am , w h at w i l l h a p p e n ? p u b l i c c l as s Te s t e x t e n d s T h r e a d { 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 ) { Te s t t = n e w Te s t ( ); t . s t ar t ( ) ; 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) N o th i n g i s d i s p l aye d .
( b ) A n i l l e g a l j ava .l a n g . I l l e g al T h r e ad S ta t e E xc e p ti o n m ay b e th r ow n b e c a u s e yo u j u s t s t ar t e d t h r e a d a n d t h re ad m i g ht have n o t ye t fi n i s h e d b e f o re you s t ar t i t a ga i n . ( c ) T h e p ro g ra m d i s p l ay s t e s t on c e . ( d ) T h e p r og ra m d i s p l ay s t e s t tw i c e .

3 . Which method on a condition should you invoke to causes the current thread to wait until the condition is signaled ?
( a) condition.wait( ) ; ( b ) condition.await (); ( c ) c o n d i t i on . wa i te d () ; ( d ) c o n d i t i on . wa i ti n g ( ) ;

4 . An instanceof describes the errors caused by your program and external circumstances . These errors can be caught and handled by your program .
( a) Runtime Exception ( b ) Error ( c ) Throwable ( d ) Exception

5 . W h a t i s d i s p l aye d o n t h e c on s o l e w h e n r u n n i n g t h e f o l l ow i n g p ro g ra m ? c l a s 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 ) { t r y { m e t h o d ( ); S y s t e m . o u t. p r i nt l n (” A f t e r t h e m e t h o d c a l l ”) ; } c a t ch ( N u mb e r Fo rm a t E x c e p t i o n e x ) { S y s t e m . o u t. p r i nt l n (” N u mb e r Fo r m at E x c e p t i o n ”) ; } c a t ch ( Ru nt i m e E x c e p t i o n e x ) { S y s t e m . o u t. p r i nt l n (” R u nt i m e E xc e p ti o n ” ); } } s t a ti c voi d me th o d ( ) { S t r i n g s = “ 5. 6 ”; I nt e g e r . p ar s e I nt ( s ) ; / / C a u s e a N u mb e rFor m a t E x c e p t i o n i nt i = 0 ; i nt y = 2 / i ; S y s t e m . o u t. p r i nt l n (“ We l c om e t o J ava ” ); } } (
a) T h e p r og ra m d i s p l ay s N u mb e rFor m a tE xc e p t i on f ol l owe d by A f t e r th e m e t h o d c a l l .
b) ( b ) T h e p r og ra m d i s p l ay s N u mb e rFor m a tE xc e p t i on f ol l owe d by R u nti m e E x c e p t i on .
c) ( c ) T h e p r og ra m d i s p l ay s N u mb e rFor m a tE xc e p t i on .
d) ( d ) T h e p r og ra m h a s a c om p i l a t i on e r ro r .


6 . W h a t i s d i s p l aye d o n t h e c on s o l e w h e n r u n n i n g t h e f ol l ow i n g p ro g ra m ? c l a s 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 ) { t r y { S y s t e m . o u t. p r i nt l n (“ We l c om e t o J ava ” ); i nt i = 0 ; i nt y = 2 /i ; S y s t e m . o u t. p r i nt l n (“ We l c om e t o J ava ” ); } c a t ch ( Ru nt i m e E x c e p t i o n e x ) { S y s t e m . o u t. p r i nt l n (“ We l c om e t o J ava ” ); } fi n a l l y { S y s t e m . o u t. p r i nt l n (“ E n d of t he b l o ck ”) ; } } }
( a) T h e p r og ra m d i s p l ay s We l c o m e t o J ava two t i m e s .
( b ) T h e p r og ra m d i s p l ay s We l c o m e t o J ava t h re e t i m e s f o ll owe d by E n d o f t h e b l o ck . ( c ) T h e p r og ra m d i s p l ay s We l c o m e t o J ava t h re e t i m e s .
( d ) T h e p r og ra m d i s p l ay s We l c o m e t o J ava two t i m e s f o l l owe d by E n d o f t h e b l o ck .

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 L i s t e n e r ( p ) ; ( b ) a d d A c t i on L i s t e n e r ( p ) ; ( c ) j b t . a d d E ve nt L i s t e n e r ( p ) ; ( d ) j b t . a d d A c t i on E ve nt Li s te n e r (p ) ;

8 . To l i s t e n t o m ou s e m ove m e nt e ve nt s , th e l i s t e n e r mu s t i m p l e m e nt t h e i nt e r f ac e .
( a) W i n d ow Li s te n e r () ( b ) M o u s e L i s t e n e r ( ) ( c ) C o m p o ne nt L i s t e n e r ( )
( d ) M o u s e M o t i on L i s t e n e r( )

9 . T h e ge tK e y C o d e () m e t h o d of t h e K e yE ve nt r e t u r n s .
( a) t h e E B S D I C c o d e o f t h e ch ar a c t e r ( b ) a ch a ra c t e r ( c ) t h e A S C I I c o d e o f t h e ch ar a c t e r ( d ) t h e U n i c o d e c o d e o f th e ch ar a c t e r

1 0. cannot be shared by a GUI component ?
( a) A C ol o r o b j e c t ( b ) A G U I c om p o n e nt ( c ) A l ayo u t o b j e c t ( d ) A Font o b j e c t

11. You can construct a JTabbed Pane using .
( a) n e w J Ta b b e d Pa n e ( C o m p on e nt ) ( b ) n e w J Ta b b e d Pa n e ( C o m p on e nt [ ] ) ( c ) n e w J Ta b b e d Pa n e ( C o m p on e nt , C om p o n e nt ) ( d ) n e w J Ta b b e d Pa n e ( )

1 2. Which of the following method will not create a LineBorder?
( a) n e w L i n e B o rd e r( C o l o r. Y E LL OW , 3 , t r u e ) ( b ) n e w L i n e B o rd e r( C o l o r. Y E LL OW , 3 ) ( c ) B o r d e r Fa c t or y. c r e a t e L i n e B o r d e r (C ol o r . Y E L LOW )
( d ) n e w L i n e B o rd e r( )

1 3. Which of the following statement is false ?
( a) Yo u c an ad d a J R a d i oB u tt o n M e nu I t e m to a J M e nu . ( b ) Yo u c an ad d a J M e nu I t e m t o a J M e nu . ( c ) You can add a JMenu to a JMenuItem . ( d ) Yo u c an ad d a J R a d i oB u tt o n M e nu I t e m to a J M e nu I te m .

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 nts a re t r u e ?
( a) J B u t t o n h a s a n a d d m e t h o d t h at e n ab l e s you t o a d d a n i n s ta n c e of A c t i on t o th e m e nu . ( b ) J B u t t o n h a s a n a d d m e t h o d t h at e n ab l e s you t o a d d a n i n s ta n c e of A c t i on L i s t e n e r t o th e m e nu . ( c ) J To o l B a r h a s a n a d d m e t h o d t h a t e n a b l e s yo u t o ad d an i n s t an c e of A c t i o n Li s te n e r t o t h e m e nu .
( d ) JTool Bar has an add method that enables you to add an instanceof Action to the menu .

1 5. W h i ch o f th e f o l l ow i n g c l a s s e s a r e n o t i n t h e j ava. aw t p ackag e ? (
a) Fo nt ( b ) C o m p o ne nt ( c ) C o l or ( d ) J Fr a m e

1 6. T h e d e f a u l t l ayou t ou t o f a c ont e nt Pan e i n a J Fr a m e i s .
( a) B o r d e r L ayou t ( b ) G r i d B a g Layo u t ( c ) F l ow Layo u t ( d ) G r i d L ayou t

1 7. T h e m e t h o d s e t s t h e b a ckg r ou n d c o l or t o ye l l ow i n J Fra m e f .
( a) f . s e tB ack g r ou n d ( C o l or . Y E L L OW ) ( b ) f . s e tB ack G r o u n d ( C ol o r . ye l l ow ) ( c ) s e t B ack g ro u n d ( C ol o r . ye l l ow ) ( d ) s e t B ack g ro u n d ( C ol o r . Y E L L OW )

1 8. G i ve n a G r a p h i c s ob j e c t g, t o d r aw an o u tl i n e o f a r e c t an g l e of w i d t h 20 an d h e i g ht 50 w i t h t h e u p p e r - l e f t c o r n e r a t ( 20 , 2 0) , yo u u s e
( a) g . d raw R e c t (2 0 , 2 0, 20 , 5 0) ( b ) g . d raw R e c t F i l l (2 0 , 5 0, 20 , 2 0) ( c ) g . d raw R e c t F i l l (2 0 , 2 0, 20 , 5 0) ( d ) g . d raw R e c t (2 0 , 5 0, 20 , 2 0)

1 9. J S p i n n e r fi r e s w h e n a n e w val u e i s s e l e c t e d .
( a) j ava x. s w i n g. e ve nt . C h a n ge E ve nt ( b ) j ava . aw t . A c t i on E ve nt ( c ) j ava . aw t . e ve nt. I te m E ve nt ( d ) j ava x. s w i n g. e ve nt . A d j u s t m e nt E ve nt

2 0. T h e m e t h o d i n t h e I n e t A d d r e s s c l a s s r e t u r n s th e I P ad d r e s s .
( a) g e t A d d re s s ( ) ( b ) g e t I PA d d r e s s ( ) ( c ) g e t I P ( ) ( d ) g e t H os t A d d r e s s ()


BBBDC DADDB DDCDD AAAAD
1 . The following method in the Thread class is not deprecated :
( a) y i e l d ( )
( b ) s u s p e n d ( );
( c ) r e s u m e ( ) ;
( d ) s t o p () ;

2 . W h i ch o f th e f o l l ow i n g m e t h o d i s a s t at i c i n j ava . l an g . T h r e a d ?
( a) s l e e p (l o n g)
( b ) r u n ( )
( c ) s t a rt ( )
( d ) j o i n ( )

3 . 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) O n c e yo u i nvo ke t h e awai t m e t h o d o n a c on d i t i on , th e l o ck i s a u to m at i c a l l y re l e as e d . O n c e t h e c o n d i t i on i s r i ght , t h e th r e a d r e - ac q u i r e s t h e l o ck a n d c o nti nu e s e x e c u t i n g .
( b ) A c on d i t i o n i s a s s o c ia t e d w i th a l o ck.
( c ) To i nvoke m e t h o d s o n a c o n d i ti o n , t h e l o ck mu s t b e ob t a i n e d fi r s t .
( d ) T h e s i g n al m e th o d on a c on d i t i o n c a u s e s t h e l o ck f o r t h e c on d i t i on t o b e r e l e as e d.

4 . T h e f o l l ow i n g c o d e c au s e s J ava t o t h row . i nt nu mb e r = I nt e g e r . M A X VA L U E + 1 ;
( 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 ) N o E x c e p t i o n s

5 . A n a l yz e t h e f ol l ow i n g p r og r am . c l a s 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 ) { t r y { S t r i n g s = ” 5. 6 ”; I nt e g e r . p ar s e I nt ( s ) ; / / C a u s e a N u mb e rFor m a t E x c e p t i o n i nt i = 0 ; i nt y = 2 / i ; S y s t e m . o u t. p r i nt l n (” We l c om e t o J ava ” ); } c a t ch ( E x c e p t i on e x ) { S y s t e m . o u t. p r i nt l n (e x) ; } } }
( a) A n e xc e p t i on i s r ai s e d d u e t o 2 / i ;
( b ) T h e p r og ra m c om p i l e s a n d r u n s w i t h o u t e x c e p t i o n s .
( c ) T h e p r og ra m h a s a c om p i l a t i on e r ro r .
( d ) A n e xc e p t i on i s r ai s e d d u e t o I nte ge r . p a rs e I nt (s );

6 . W h a t i s w ro n g i n t h e f ol l ow i n g p r og r am ? c l a s s Te s t { p u b l i c s t at i c vo i d m a i n ( S t ri n g [ ] a r gs ) { t r y { S y s t e m . o u t. p r i nt l n (“ We l c om e t o J ava ” ); } } }
( a) Yo u c an n o t h ave a t r y b l o ck w i t h o u t a c a tch b l o ck or a fi n a l l y b l o ck .
( b ) A m e th o d c al l th a t d o e s n ot d e c l ar e e x c e p t i o ns c a n n ot b e p l a c e d i n s i d e a t r y b l o ck .
( c ) N o th i n g i s w r o ng .
( d ) Yo u c an n o t h ave a t r y b l o ck w i t h o u t a c a tch b l o ck .

7 . 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 a s s e rt i o n s t a t e m e nt?
( a) a s s e r t s u m > 1 0 && s u m < 5 * 1 0 : “s um i s ” + s u m ;
( b ) a s s e r t ( i < 1 0) ;
( c ) a s s e r t “ s u m i s ” + s u m ;
( d ) a s s e r t ( i > 1 0) ;

8 . To b e a l i s te ne r f o r A c t i on E ve nt , a n o b j e c t mu s t b e an i n s t an c e o f .
( a) W i n d ow Li s te n e r
( b ) A c t i o n E ve nt
( c ) E ve nt Ob j e c t
( d ) A c t i o n Li s te n e r

9 . To ch e ck w h e t h e r a D E L E T E ke y i s p re s s e d or r e l e as e d , w h i ch h a n d l e r s h ou l d b e u s e d ?
( a) ke y A c t i ve ( K e yE ve nt e )
( b ) ke y Typ e d (K e y E ve nt e )
( c ) ke y Re l e as e d (K e y E ve nt e )
( d ) ke y I n ac ti ve ( K e y E ve nt e )

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) p r e f e r r e d S i z e
( b ) b a ckg r ou n d
( c ) f o r e gr o u n d
( d ) f o nt

1 1. W h i ch o f th e f o l l ow i n g a r e t h e i nval i d m e t h o d s i n J Tab b e d Pan e ?
( a) g e t T i t l e At( i n d e x )
( b ) g e t Ta b b e d C o u nt( )
( c ) g e t To o l T i p Te x t At (i n d e x)
( d ) g e t Ta b P l a c e m e nt ( )

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) 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 )
( 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 ) 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 )



1 3. i s th e a c t i on t h a t c a u s e s a p o p u p m e nu t o b e d i s p l aye d .
( a) Po p u p r e a c ti o n
( b ) Po p u p e ve nt
( c ) Po p u p t r i gg e r
( d ) Po p u p a c t io n


1 4. a l l ow s yo u t o c r e a t e c u s to m b u t t on s .
( a) A n o p t i on d i al o g
( b ) A m e s s a ge d i al o g
( c ) A n i n p u t d i al o g
( d ) A c on fi r m a ti o n d i a l og

15. W h i ch o f th e f o l l ow i n g a r e s u b c l as s e s of j ava. aw t . C om p on e nt ?
( a) H e l p e r c l a s s e s s u ch a s C ol o r a n d Fo nt
( b ) L ayou t m an a ge r s
( c ) S w i n g u s e r i nt e r f a c e c l a s s e s
( d ) A l l U t i l i ty c l a s s e s

1 6. H ow m a ny f r am e s ar e d i s p l aye d ? i m p o r t j avax . s w i n g . * ; p u b l i c c l as s Te s t e xt e n d s J Fr a m 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[ ] ar g s ) { J Fr a m e f 1 = ne w Te s t ( ) ; J Fr a m e f 2 = ne w Te s t ( ) ; J Fr a m e f 3 = ne w Te s t ( ) ; f 1 . s e t V i s i b l e ( t r u e ) ; f 2 . s e t V i s i b l e ( t r u e ) ; f 3 . s e t V i s i b l e ( t r u e ) ; } }
( a) 1 .
( b ) 0 .
( c ) 2 .
( d ) 3 .

1 7. To s p e c i f y a f ont t o b e b o l d a n d i t al i c , u s e t h e f o nt s tyl e va l u e
( a) Fo nt . I TA L I C
( b ) Fo nt . B O LD
( c ) Fo nt . P L A I N
( d ) Fo nt . B O LD + Fo nt . I TA L I C

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 n c i r c l e w i t h r ad i u s 2 0 c e nte re d a t ( 50 , 5 0) , yo u u s e
( a) g . d raw O val ( 5 0, 50 , 2 0 , 20 )
( b ) g . d raw O val ( 3 0, 30 , 2 0 , 2 0)
( c ) g . d raw O val ( 3 0, 30 , 4 0 , 40 )
( d ) g . d raw O val ( 5 0, 50 , 4 0 , 4 0)

1 9. A l i s te n e r o f a J L i s t mu s t im p l e m e nt .
( a) j ava x. s w i n g. e ve nt . A d j u s t m e nt L i s t e n e r
( b ) t h e j ava . aw t . A c t i o n L i s t e n e r i nt e r f ac e
( c ) j ava x. s w i n g. e ve nt . C h a n ge L i s t e n e r
( d ) t h e j ava . aw t . I t e m L i s t e n e r i nte rf ac e

2 0. T h e s e r ve r l i s t e n s f or a c on n e c t i on r e q u e s t f r om a c l i e nt u s i n g t h e f ol l ow i n g s t at 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 = s e r ve r S o cke t. g e t S o cke t ( )
( c ) S o cke t s = n e w S o cke t( S e r ve r N am e ) ;
( d ) S o cke t s = s e r ve r S o cke t. a c c e pt ( )

A A D D D A C D C A B C C A C D D C C D
1 . 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 n o t d e fi n e d i n t h e Ob j e c t c l a s s ? ( a) wa i t( ) ( b ) n o ti f y( ) ( c ) n o ti f yA l l ( ) ( d ) s l e e p (l o n g m i l l i s e c o n d s )

2 . W h i ch o f th e f o l l ow i n g m e t h o d i s a s t at i c i n j ava . l an g . T h r e a d ? ( a) s l e e p (l o n g) ( b ) s t a rt ( ) ( c ) r u n ( ) ( d ) j o i n ( )

3 . Yo u c an n o t c r e a te a b l o ck i ng q u e u e u s i n g . ( a) A r r ay B l o ck i n gQ u e u e ( b ) P r i o ri ty B l o ck i n gQ u e u e ( c ) L i n ke d B l o cki n g Q u e u e ( d ) P r i o ri ty Qu e u e

4 . A J ava e x c e p ti o n i s an i n s t an c e o f . ( a) E r r or ( b ) T h r owa b l e ( c ) R u nt i m e E x c e p t i on ( d ) E x c e p t i o n

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 am 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 ) { S t r i n g s = “ ab c ”; S y s t e m . o u t. p r i nt l n (s . ch ar At (3 ) ) ; } } ( a) 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 ( 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 i t h m e t i c 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 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 . ( d ) 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 .

7 . C l i ck i n g t h e c l o s i n g b u t t on on th e u p p e r - ri g ht c o rn e r of a f r am e g e n e r at e s a (n ) e ve nt . ( a) W i n d ow E ve nt ( b ) C o m p o ne nt E ve nt ( c ) M o u s e M o t i on E ve nt ( d ) I t e m E ve nt

8 . To ge t th e x c o o rd i n a t e o f t h e m ou s e p o i nt e r f o r t h e M o u s e E ve nt e vt , yo u u s e . ( a) E ve nt . ge t Po i nt ( ) . x ( b ) E ve nt . ge t Po i nt ( x , y ) ( c ) e v t . ge tX ( ) ( d ) e v t . ge tX Y ( )

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) r e s i z a b l e ( b ) i c o n I m a ge ( c ) c o nte nt Pa n e ( d ) t i t l e

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) p r e f e r r e d S i z e ( b ) b a ckg r ou n d ( c ) f o nt ( d ) f o r e gr o u n d


1 1. Yo u c an c on s tr u c t a J S p l i t Pa n e u s i n g . ( a) n e w J S p l i tPan e ( C o m p o n e nt, C om p on e nt ) ( b ) n e w J S p l i tPan e ( ) ( c ) n e w J S p l i tPan e ( C o m p o n e nt [ ] ) ( d ) n e w J S p l i tPan e ( C o m p o n e nt)

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 ) n e w E t ch e d B o ar d e r ( ) ( c ) 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 ( ) ( 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. A J R a d i oB u tt o n M e nu I t e m is a s u b c l as s o f . ( a) J M e nu I t e m ( b ) A b s t r ac tB u t to n ( c ) J M e nu ( d ) J C o m p o n e nt

1 4. i s u s e d t o r e c e i ve i n p u t f r om th e u s e r . ( a) A n i n p u t d i al o g ( b ) A m e s s a ge d i al o g ( c ) A c on fi r m a ti o n d i a l og ( d ) A n o p t i on d i al o g

1 5. W h i ch o f th e f o l l ow i n g c l a s s e s a r e n o t i n t h e j ava. aw t p ackag e ? ( a) Fo nt ( b ) J Fr a m e ( c ) C o l or ( d ) C o m p o n e nt

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 b a ckg r ou n d c o l or t o ye l l ow i n J Fra m e f . ( a) s e t B ack g ro u n d ( C ol o r . Y E L L OW ) ( b ) s e t B ack g ro u n d ( C ol o r . ye l l ow ) ( c ) f . s e tB ack G r o u n d ( C ol o r . ye l l ow ) ( d ) f . s e tB ack g r ou n d ( C o l or . Y E L L OW )

1 8. 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) T h e p ai nt C o m p on e nt me th o d i s a u t om a t i c al l y i nvoke d by t h e J V M . Yo u s h o u l d n e ve r i nvoke i t d i r e c tl y. ( b ) W h e n e ve r a G U I c o m p o n e nt i s di s p l aye d , i t s G r ap h i c s o b j e c t i s a u t om a t i c al l y c r e at e d . ( c ) I nvok i n g r e p ai nt ( ) c a u s e s p ai nt C o m p on e nt to b e i nvo ke d by t h e J V M . ( d ) Yo u m ay c r e a te a G r a p h i c s o b j e c t u s i n g n e w G r a p h i c s ( ) .

1 9. D e f a u l t Li s tC e l l Re n de re r c a n d i s p l ay . ( a) b o t h s t r i n g an d i c on ( b ) a s t r i n g or an i c on ( c ) o n l y an i c on ( d ) o n l y a s t r i n g

2 0. To c r e at e an I n p u t S tr e a m t o r e a d f r o m a fi l e o n a We b s e r ve r , yo u u s e t h e m e t h o d i n t h e U RL c l as s . ( a) c o n n e c t S t re am ( ) ; ( b ) g e t I n p u t S tr e a m ( ); ( c ) o b ta i n I n p u t S t re am ( ) ; ( d ) o p e n S t r e am ( ) ;

D A D B B A A C C A B B C A B B D D B D
1 . W hy d o e s th e f o l l ow i n g c l a s s h ave a s ynt ax e r ro r ? i m p o r t j ava. a p p l e t . *; p u b l i c c l as s Te s t e x t e n d s A p p l e t i m p l e m e nt s Ru n n a b l e { p u b l i c vo i d i n i t ( ) t h row s I nte rr u p t e d E x c e p t i o n { T h r e a d t = n e w T h r e a d (t h i s ) ; t . s l e e p ( 1 00 0) ; } p u b l i c s y n ch r o n i z e d vo i d r u n ( ) { } }
( a) Yo u c an n o t p u t t h e ke y wor d s y n ch ro n i z e d i n t h e r u n ( ) m e t h o d .
( b ) T h e i n i t ( ) m e t h o d i s d e fi n e d i n t h e A p p l e t c l a s s , a n d i t i s ove r ri d d e n i n c o r r e c t l y b e c au s e i t c an n o t c l ai m e x c e p t i o n s i n th e s u b c l as s . ( c ) T h e s l e e p ( ) m e t h o d i s n o t i nvo ke d c o rr e c tl y ; i t s h ou l d b e i nvoke d as T h r e a d . s l e e p ( 10 0 0) . ( d ) T h e s l e e p ( ) m e t h o d s h ou l d b e p u t i n t h e t r y- c a tch b l o ck. T h i s i s t h e o n l y r e a s on f or th e c o m p i l at i o n f a i l u r e .

2 . H ow d o you c re at e a c as h e d t h r e ad p o ol ?
( a) E x e c u t o rS e rv i c e e x e c u t o r = E x e c u t o rs . n e w C a ch e d T h r e a d Po o l ( 1) ;
( b ) E x e c u t o rS e rv i c e e x e c u t o r = E x e c u t o rs . n e w C a ch e d T h r e a d Po o l ( 2) ;
( c ) E x e c u t o rS e rv i c e e x e c u t o r = E x e c u t o rs . n e w C a ch e d T h r e a d Po o l ( 3)
; ( d ) E x e c u t o rS e rv i c e e x e c u t o r = E x e c u t o rs . n e w C a ch e d T h r e a d Po o l ( );

3 . W h i ch m e t h o d o n a c o n d i t i on s h o u l d yo u i nvoke t o c a u s e s t h e c u r r e nt t h r e a d t o wai t u nti l t h e c o n d i ti o n i s s i g n al e d ?
( a) c o n d i t i on . awa i t ( ); ( b ) c o n d i t i on . wa i te d () ; ( c ) c o n d i t i on . wa i t( ) ; ( d ) c o n d i t i on . wa i ti n g ( ) ;

4 . W h i ch o f th e f o l l ow i n g m e t h o d s c an b e u s e d t o o bt a i n a p e rm i t f ro m a S e m ap h o re s ?
( a) a c q u i re () ( b ) a s k () ( c ) d e l e t e ( ) ( d ) g e t ()

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) Yo u u s e t h e ke y wo rd t h row s to d e c l ar e e x c e p t i on s i n t h e m e t h o d h e ad i n g . ( b ) I f a ch e cke d e x c e p ti o n o c c u rs i n a m e th o d , i t n e e d n ot t o b e e i t h e r c au g ht or d e c l a re d t o b e th r ow n f r o m t h e m e t h o d . ( c ) A m e th o d may d e c l a r e t o t h r ow mu l t i p l e e x c e p t i on s .
( d ) To th r ow a n e x c e p t i o n , u s e t h e ke y wo r d t h row .

6 . W h a t i s d i s p l aye d o n t h e c on s o l e w h e n r u n n i n g t h e f ol l ow i n g p ro g ra m ? c l a s 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 ) { t r y { S y s t e m . o u t. p r i nt l n (“ We l c om e t o J ava ” ); i nt i = 0 ; i nt y = 2 /i ; S y s t e m . o u t. p r i nt l n (“ We l c om e t o J ava ” ); } c a t ch ( Ru nt i m e E x c e p t i o n e x ) { S y s t e m . o u t. p r i nt l n (“ We l c om e t o J ava ” ); } fi n a l l y { S y s t e m . o u t. p r i nt l n (“ E n d of t he b l o ck ”) ; } S y s t e m . o u t. p r i nt l n (“ E n d of t he b l o ck ”) ; } }
( a) T h e p r og ra m d i s p l ay s We l c o m e t o J ava two t i m e s f o l l owe d by E n d o f t h e b l o ck . ( b ) T h e p r og ra m d i s p l ay s We l c o m e t o J ava t h re e t i m e s f o ll owe d by E n d o f t h e b l o ck .
( c ) T h e p r og ra m d i s p l ay s We l c o m e t o J ava two t i m e s f o l l owe d by E n d o f t h e b l o ck two t i m e s .
( d ) Yo u c an n o t c a tch Ru nt i m e E x c e p t i o n e r r o rs .

7 . W h i ch o f th e f o l l ow i n g i s f a l s e ?
( a) u s e as s e r t i on s f o r ar g u m e nt ch e ck i n g i n p u b l i c m e t ho d s .
( b ) U s e as s e r t i on s t o re affi r m a s s u m p t i o n s . ( c ) E x c e p t i o n h a n d l i n g ad d r e s s e s r o b u s t n e s s w h e r e a s a s s e r t i o n a d d re s s e s c o rr e c tn e s s . ( d ) E x c e p t i o n h a n d l i n g d e a l s w i t h u nu s u a l c i r c u m s ta n c e s d u r i n g p r og r am e x e c u t i o n . A s s e r t i on s a r e i nt e n d e d t o e n s u r e t h e c o r re c t n e s s of t h e p r og r am .











8 . A n a l yz e t h e f ol l ow i n g c o d e . 1 . i m p o rt j ava . aw t. * ; 2 . i m p o rt j ava . aw t. e ve nt . *; 3 . i m p o rt j ava x . s w i n g . *; 4 . 5 . p u b l i c c l a s s Te s t e x t e n d s J Fr am e { 6 . p u b l i c Te s t ( ) { 7 . J B u t t on j b t OK = n e w J B u t t on ( “ OK ” ) ; 8 . J B u t t on j b t C an c e l = n e w J B u t t on ( “ C a n c e l ” ); 9 . ge tC ont e ntPa n e ( ) . ad d ( j b t O K ) ; 1 0. g e t C o nt e nt Pa n e ( ). a d d ( j b t C an c e l ) ; 1 1. j b tO K . a d d A c t i on L i s t e n e r ( t h i s ) ; 1 2. j b tC an c e l . a d d A c t i o n Li s te n e r (t h i s ) ; 1 3. } 1 4. 1 5. p u b l i c vo i d a c t i o n p e r f or m e d ( A c t i o n E ve nt e ) { 1 6. S y s t e m . o u t . p ri nt l n ( “A b u t to n i s c l i cke d ”) ; 1 7. } 1 8. 1 9. p u b l i c s t at i c vo i d m a i n ( S tr i n g [ ] a r gs ) { 2 0. J Fr am e f r am e = n e w Te s t( ) ; 2 1. f ra m e . s e tS i z e (3 0 0, 30 0) ; 2 2. f ra m e . s e tD e f a u l t C l o s e O p e r at i o n (J Fr am e . E X I T O N C L O S E ) ; 2 3. f ra m e . s e tV i s i b l e (t r u e ) ; 2 4. } 2 5. }

( a) T h e p r og ra m h a s s y nt a x e r r or s on Li n e 1 5 b e c a u s e th e s i g n at u r e o f ac t i o n p e r f o rm e d i s w r on g . ( b ) T h e p r og r am h as r u nt i m e e rr o r s o n Li n e s 9 an d 10 b e c a u s e j b t OK an d j b t C a n c e l ar e ad d e d t o t h e s a m e l o c a t i on i n t h e c ont a i n e r . ( c ) T h e p r og ra m h a s s y nt a x e r r or s on Li n e 2 0 b e c a u s e n e w Te s t ( ) i s as s i gn e d t o f r am e (a var i a b l e o f J Fr am e ) .
( d ) T h e p r og ra m h a s s y nt a x e r r or s on Li n e s 1 1 an d 12 b e c au s e Te s t d o e s n o t i m p l e m e nt A c t i o n Li s te n e r .

9 . T h e ge tK e y C o d e () m e t h o d of t h e K e yE ve nt r e t u r n s .
( a) t h e E B S D I C c o d e o f t h e ch ar a c t e r
( b ) t h e U n i c o d e c o d e o f th e ch ar a c t e r ( c ) a ch a ra c t e r ( d ) t h e A S C I I c o d e o f t h e ch ar a c t e r

1 0. c a n n ot b e s h ar e d by a G U I c om p o n e nt ?
( a) A Font o b j e c t
( b ) A C ol o r o b j e c t
( c ) A l ayo u t o b j e c t
( d ) A G U I c om p o n e nt

1 1. Yo u c an c on s tr u c t a J Ta b b e d Pa n e u s i n g .
( a) n e w J Ta b b e d Pa n e ( C o m p on e nt [ ] )
( b ) n e w J Ta b b e d Pa n e ( )
( c ) n e w J Ta b b e d Pa n e ( C o m p on e nt )
( d ) n e w J Ta b b e d Pa n e ( C o m p on e nt , C om p o n e nt )

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 a Li n e B o rd e r?
( a) n e w L i n e B o rd e r( C o l o r. Y E LL OW , 3 , t r u e )
( b ) n e w L i n e B o rd e r( C o l o r. Y E LL OW , 3 )
( c ) n e w L i n e B o rd e r( )
( d ) B o r d e r Fa c t or y. c r e a t e L i n e B o r d e r (C ol o r . Y E L LOW )

1 3. Yo u c an n o t s e t an i m a g e I c o n p r o p e r ty o n .
( a) a J C h e ck B ox M e nu I t e m
( b ) a J M e nu I t e m
( c ) a J R ad i o B u t t on M e nu I te m
( d ) a J m e nu B a r


1 4. a re r e f e r r e d t o a s h e av y we i ght c o m p o n e nts .
( a) G U I c o m p on e nt s
( b ) N o n - G U I c o m p on e nt s
( c ) S w i n g c o m p o n e nts
( d ) AW T c o m p on e nt s

1 5. W h i ch o f th e f o l l ow i n g c l a s s e s i s a h e av y we i g ht c o m p o ne nt ?
( a) J Pa n e l ( b ) J Fr a m e ( c ) J B u t t o n ( d ) J Te x tF i e l d

1 6. H ow m a ny f r am e s ar e d i s p l aye d ? i m p o r t j avax . s w i n g . * ; p u b l i c c l as s Te s t e x t e n d s J Fr a m 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[ ] ar g s ) { J Fr a m e f 1 = n e w Te s t ( ) ; J Fr a m e f 2 = n e w Te s t ( ) ; J Fr a m e f 3 = n e w Te s t ( ) ; f 1 . s e t V i s i b l e ( t r u e ) ; f 2 . s e t V i s i b l e ( t r u e ) ; f 3 . s e t V i s i b l e ( t r u e ) ; } }
( a) 1 . ( b ) 3 . ( c ) 2 . ( d ) 0 .

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 a p h i c s o b j e c t g, t o d r aw a p o l y go n t o c on n e c t p oi nt s ( 3 , 3) , ( 4 , 10 ) , (1 0 , 20 ) , (2 , 1 00 ), yo u u s e
( a) g . d raw Po l yg on ( n e w i nt [ ] 3, 4 , 1 0 , 2 , n e w i nt [ ] 3 , 1 0, 20 , 1 0 0, 4 )
( b ) g . d raw Po l yl i n e ( 3 , 4 , 1 0, 2, 3, 10 , 2 0, 10 0 , 4)
( c ) g . d raw Po l yg on ( 3 , 4 , 1 0, 2, 3, 10 , 2 0, 10 0 , 4)
( d ) g . d raw Po l yl i n e ( n e w i nt [ ] 3, 4 , 1 0 , 2 , n e w i nt [ ] 3 , 1 0, 20 , 1 0 0, 4 )


1 9. I f yo u c re at e a J S p i n n e r ob j e c t w i th o u t s p e c i f y i n g a m o d e l , t h e s p i n n e r d i s p l ays .
( a) a s e q u e n c e o f d o u b l e val u e s
( b ) a s e q u e n c e o f n o n - n e g a ti ve i nt e g e r s
( c ) a s e q u e n c e o f p o s i t i ve i nt e g e r s
( d ) a s e q u e n c e o f i nt e g e r s

2 0. To c r e at e an I n p u t S tr e a m o n a s o cke t s , yo u u s e .
( a) I n p u t S t r e am i n = s . g e t S t re am ( ) ;
( b ) I n p u t S t r e am i n = s . g e t I n p u t S t re am ( ) ;
( c ) I n p u t S t r e am i n = n e w I n p u t S t re a m ( s ) ;
( d ) I n p u t S t r e am i n = s . o b t ai n I n p u t S t r e am ( ) ;


B D A A B C A D B D B C D D B B D A D B


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 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 .
( b ) R u nt i m e E r ro r ( c ) 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 . ( d ) 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 .

2 . 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 s yn ch r o n i z e d i n s ta n c e m e t h o d d o e s n t a c q u i r e a l o ck o n t h e o b j e c t f o r w h i ch th e m e t h o d wa s i nvoke d .
( b ) A s yn ch r o n i z e d i n s ta n c e m e t h o d ac q u i r e s a l o ck on th e c l a s s o f th e ob j e c t f or w h i ch t h e m e t h o d wa s i nvoke d .
( c ) A s yn ch r o n i z e d s ta t e m e nt i s p l ac e d i n s i d e a s y n ch r on i z e d b l o ck. ( d ) A s yn ch r o n i z e d s ta t e m e nt c a n b e u s e d t o a c q u i re a l o ck on a ny ob j e c t , n ot j u s t t h i s o b j e c t , w h e n e x e c u t i n g a b l o ck of t h e c o d e i n a m e t h o d .


3 . Yo u c an n o t c r e a te a b l o ck i ng q u e u e u s i n g .
( a) P r i o ri ty B l o ck i n gQ u e u e ( b ) L i n ke d B l o cki n g Q u e u e ( c ) A r r ay B l o ck i n gQ u e u e ( d ) P r i o ri ty Qu e u e

4 . W h i ch o f th e f o l l ow i n g m e t h o d s c an b e u s e d t o o bt a i n a p e rm i t f ro m a S e m ap h o re s ? ( a) d e l e t e ( ) ( b ) g e t () ( c ) a s k () ( d ) a c q u i re ()

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 ) { O b j e c t o = nu l l ; S y s t e m . o u t. p r i nt l n (o ) ; } }
( a) N o 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 i t h m e t i c E x c e p t i o n ( d ) A r r ay I n d e x O u t O f B ou n d s E xc e p t i on

6 . W h a t i s d i s p l aye d o n t h e c on s o l e w h e n r u n n i n g t h e f ol l ow i n g p ro g ra m ? c l a s 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 ) { t r y { S y s t e m . o u t. p r i nt l n (We l c om e t o J ava ); i nt i = 0 ; i nt y = 2 /i ; S y s t e m . o u t. p r i nt l n (We l c om e t o J ava ); } fi n a l l y { S y s t e m . o u t. p r i nt l n (E n d of t he b l o ck ) ; } S y s t e m . o u t. p r i nt l n (E n d of t he b l o ck ) ; } }
( a) T h e p r og ra m d i s p l ay s We l c o m e t o J ava two t i m e s f o l l owe d by E n d o f t h e b l o ck .
( b ) T h e p r og ra m d i s p l ay s We l c o m e t o J ava two t i m e s f o l l owe d by E n d o f t h e b l o ck two t i m e s .
( c ) T h e p r og ra m d i s p l ay s We l c o m e t o J ava an d E n d o f t h e b l o ck, a n d t h e n te rm i n a t e s b e c a u s e o f an u n h an d l e d e x c e p t i o n . ( d ) T h e p r og ra m d i s p l ay s We l c o m e t o J ava t h re e t i m e s f o ll owe d by E n d o f t h e b l o ck .

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 E ve nt L i s t e n e r ( p ) ;
( c ) j b t . a d d A c t i on L i s t e n e r ( p ) ; ( d ) a d d A c t i on L i s t e n e r ( p ) ;

8 . E ve r y e ve nt ob j e c t h as t h e m e t h o d .
( a) g e t W h e n ( ) ( b ) g e t A c t i on C o m m an d ( )
( c ) g e t T i m e S t am p ( )
( d ) g e t S ou r c e ( )

9 . 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) Yo u n e e d n o t al way s s p e c i f y a l i s te n e r w h e n c r e at i n g a T i m e r ob j e c t . ( b ) To s t op a ti m e r , i nvo ke t i m e r. s to p ( ) . ( c ) To s t ar t a t i m e r , i nvoke t i m e r . s t a rt ( ) . ( d ) Yo u c an ad d mu l t i p l e l i s t e n e r s f or a T i m e r ob j e c t .

1 0. S u p p o s e th a t a c o nta i n e r c u s e s a C a rd L ayo u t m a n ag e r p . W h i ch of t h e f o l l ow i n g m e th o d i s n o t va l i d ?
( a) p . l a s t (c ) ( b ) c . p . fi r s t ( ) ( c ) p . p r e v i ou s (c ) ( d ) p . n e x t ( c )

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 i n a r ow o r a c o l u m n . ( a) B o r d e r L ayou t ( b ) B ox Layo u t ( c ) G r i d L ayou t ( d ) F l ow Layo 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 a Li n e B o rd e r?
( a) n e w L i n e B o r de r( C o l o r. Y E LL OW , 3 , t r u e )
( b ) B o r d e r Fa c t or y. c r e a t e L i n e B o r d e r (C ol o r . Y E L LOW )
( c ) n e w L i n e B o r de r( ) ( d ) n e w L i n e B o r de r( C o l o r. Y E LL OW , 3 )


1 3. 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) Yo u c an ad d a J M e nu t o a J Pop u p M e nu .
( b ) Yo u c an ad d a J C h e ck B ox M e nu I te m t o a J Pop u p M e nu . ( c ) Yo u c an ad d a J M e nu I t e m t o a J Po p u p M e nu . ( d ) Yo u c an ad d a J R a d i oB u tt o n M e nu I t e m to a J Po p u p M e nu .

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 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 . ( b ) A J To ol B ar m ay b e fl oa t ab l e .
( c ) 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. ( d ) 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 .

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 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 .
( b ) 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. ( c ) To d i s 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 o m 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 . ( d ) 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 .

1 6. H ow m a ny f r am e s ar e d i s p l aye d ? i m p o r t j avax . s w i n g . * ; p u b l i c c l as s Te s t e xt e n d s J Fr a m 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[ ] ar g s ) { J Fr a m e f 1 = n e w Te s t ( ) ; J Fr a m e f 2 = n e w Te s t ( ) ; J Fr a m e f 3 = n e w Te s t ( ) ; f 1 . s e t V i s i b l e ( t r u e ) ; f 2 . s e t V i s i b l e ( t r u e ) ; f 3 . s e t V i s i b l e ( t r u e ) ; } }
( a) 3 . ( b ) 1 . ( c ) 2 . ( d ) 0 .

1 7. T h e d e f a u l t l ayou t ou t o f a J Pa n e l i s . ( a) B o r d e r L ayou t ( b ) G r i d L ayou t ( c ) F l ow Layo u t ( d ) d e f a u l t L ayou t

1 8. G i ve n a G r a p h i c s o b j e c t g, t o d r aw a p o l y go n t o c on n e c t p oi nt s ( 3 , 3) , ( 4 , 10 ) , (1 0 , 20 ), ( 2 , 10 0 ), yo u u s e
( a) g . d raw Po l yl i n e ( 3 , 4 , 1 0, 2, 3, 10 , 2 0, 10 0 , 4 )
( b ) g . d raw Po l yg on ( n e w i nt [ ] 3, 4, 1 0 , 2 , n e w i nt[ ] 3 , 1 0, 20 , 1 0 0, 4 ) ( c ) g . d raw Po l yl i n e ( n e w i nt [ ] 3, 4, 1 0 , 2 , n e w i nt[ ] 3 , 1 0, 20 , 1 0 0, 4 ) ( d ) g . d raw Po l yg on ( 3 , 4 , 1 0, 2, 3, 10 , 2 0, 10 0 , 4 )

1 9. J L i s t 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 x. s w i n g. e ve nt . C h a n ge 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 . aw t . e ve nt. I te m E ve nt ( d ) j ava . aw t . A c t i on E ve nt

2 0. W h e n c r e at i n g a s e r ve r o n a p o r t t h at i s a l re ad y i n u s e , .
( a) t h e s e r ve r i s b l o cke d u nt i l t h e p o r t i s ava i l a b l e . ( b ) t h e s e r ve r e n c ou nt e r s a f at a l e r r or an d mu s t b e te r m i n a t e d .
( c ) t h e s e r ve r i s c r e a t e d w i t h n o p ro b l e m s .
( d ) j ava . n e t . B i n d E x c e p t i o n o c c u r s .


CADDA CCDAB BCACA ACBAD