question 1)
+ w, ?# b c# Z! q, ?which of the following lines will compile without warning or error.
- s; F2 X1 W5 s& m! \- v1) float f=1.3; l+ K! r3 j ]" v7 S- q" X
2) char c='a';
3 b/ f: z/ Z9 }* Q3) byte b=257;
f; g* \; p1 ~# m. H4) boolean b=null;
2 \2 \' C' H. B' o! S+ _3 D5) int i=10; 1 l8 z% C; g% s1 Y! K1 ^& K5 K* d
answer to question 1
/ a3 \; J7 F Q4 ^3 d% m0 ]$ P--------------------------------------------------------------------------------
3 H. W% i+ s+ w" kquestion 2) + ^8 y. m# b8 c1 P8 M
what will happen if you try to compile and run the following code
- E4 t b9 P" Gpublic class myclass {
: L, x: i8 E# J% i4 e6 [public static void main(string arguments[]) {
( B1 a0 |' z" e/ j8 jamethod(arguments);
6 T, J, J- m1 [( l" P j5 x} 3 @" k+ {5 U4 Z* c
public void amethod(string[] arguments) {
: J3 Y2 ]& W+ U, f) L. c3 X @: i9 Esystem.out.println(arguments); 9 Z+ ^: ]! P x7 o$ ~
system.out.println(arguments[1]); * ~6 s4 ?9 A- ~" T7 ^0 _3 |' L; Z8 j
}
: z5 J6 L( `. S9 F; r) ?} - Y9 f' [/ K1 k' ~# u" c0 R
1) error can%26acute;t make static reference to void amethod. # B/ W$ s/ Q }1 ~
2) error method main not correct 4 I* O p' I5 ~4 H% X
3) error array must include parameter ' I3 l' A5 b' t& p! J0 b
4) amethod must be declared with string
6 |9 z4 P9 x6 @" I/ wanswer to question 2 % l6 |: {1 r& z& P& H; d/ w$ x
--------------------------------------------------------------------------------
4 Q j, Q& P1 `/ n0 c3 ]1 z/ E x6 oquestion 3) & H3 ]0 W0 a1 G* L- E( V
which of the following will compile without error
1 T, S0 k; P$ }4 g( O1) & o) D1 ^7 S1 T m
import java.awt.*; $ ?; j9 ~) [; z/ \
package mypackage; ! {! X. O7 e$ D
class myclass {} ' ^' E* y9 s# U$ a: i
2) $ R1 ~( z3 _- s3 Y/ F& X
package mypackage; 7 ~8 ]+ t# S* }. ] S0 U+ r. i2 {2 I
import java.awt.*;
# n+ U5 p$ s V* z6 A0 V5 C6 _class myclass{}
s# @* V% t$ t8 X3) , u- s! e( t6 K
/*this is a comment */
( F' c. P0 p. L, b$ E- Dpackage mypackage; 1 M& J2 G Y4 F4 e9 T% [+ y. e
import java.awt.*;
" z; d: Z: Q1 Aclass myclass{}
! [6 R% D8 h7 l3 ^- Sanswer to question 3
) R. f- x" o. h, m. ]7 C" D5 [5 I1 {* Y% U4 a$ `, M8 D
-------------------------------------------------------------------------------- |