Monday, April 16, 2012

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

0 comments:

Post a Comment