v.add(99); </p>4 vector v=new vector(100);
5 I) V( S) h' sv.addelement('99');
; a, p' S; v& k/ V5 Lanswer to question 47 - h, f! S: w1 W2 d
-------------------------------------------------------------------------------- & o) j& t0 w+ a3 u G
question 48)
- e+ H' \& k2 l+ c8 W' R9 p5 Kyou have created a simple frame and overridden the paint method as follows : o, x2 Q) m4 a6 h1 U
public void paint(graphics g){ % r9 u& d+ _3 w& n
g.drawstring('dolly',50,10);
+ s6 d3 k# t; X' W2 [6 ?) C7 T} . G& L9 X' L8 c9 j7 T5 i# i
what will be the result when you attempt to compile and run the program? $ U- V) B4 w0 C) p
1) the string 'dolly' will be displayed at the centre of the frame
0 `; e' t) ?- j2 h, U/ O2) an error at compilation complaining at the signature of the paint method * U7 K( N2 x) y4 ?- P
3) the lower part of the word dolly will be seen at the top of the frame, with the top hidden. . R5 E3 t4 Q1 S o
4) the string 'dolly' will be shown at the bottom of the frame.
9 g2 k) q3 D) O) g9 Aanswer to question 48 & v9 m: c! u: o" Q4 s& l" ~
--------------------------------------------------------------------------------
; ?" J: H7 l1 ~8 \4 I! Cquestion 49)
% V: c; a! q; e5 fwhat will be the result when you attempt to compile this program?
7 C1 ]2 r, `( _( M6 K4 bpublic class rand{ / K" b% }$ K a, S$ v, ?
public static void main(string argv[]){
; o: A! H( J4 N8 B/ z0 @int irand;
+ e/ \% B1 j+ U. Iirand = math.random();
: J1 y6 Z3 s2 ^1 f/ i C* |! |- Asystem.out.println(irand); % F1 c8 ]9 |# j- ~+ t
}
" _4 {: T: \ |) j} 3 }$ Y4 Z( b- B" O3 N2 i* c
1) compile time error referring to a cast problem V' h( h0 _6 X) n* k( u8 r3 e
2) a random number between 1 and 10
+ ]6 S+ w) T! V3 [- p9 j3) a random number between 0 and 1 & b. P; E/ g$ U0 a- E" ]* S, b
4) a compile time error about random being an unrecognised method
, l2 E$ J' ]. v- canswer to question 49 |