Vous êtes sur la page 1sur 13

J2EE MOCK TEST

[1] Which of the following statements are correct? I. Integer literals create an int value. II. In Java, when a literal value is assigned to a byte or short variable, an error is generated even if the literal value is within the range of the target type.

hoice a

!nly I is correct.

hoice b hoice c

!nly II is correct

"oth I and II are correct

hoice d

"oth I and II are incorrect

[#] Which of the following statements are correct? I. In Java, a byte is a signed $%bit type entity. II. II. &he smallest integer data type is short. hoice a !nly I is correct.

hoice b

!nly II is correct.

hoice c

"oth I and II are correct.

hoice d

"oth I and II are incorrect.

[3]

Which of the following statements are correct? I. In Java, char is 8-bit type. II. We have negative chars in Java.
hoice a !nly II is correct. !nly I is correct.

hoice b

hoice c

"oth I and II are correct.

hoice d

"oth I and II are incorrect.

['] Which of the following statements are correct? I. We can operate on chars as if they are integers. II. Java has a simple data type boolean for logical values. hoice a !nly I is correct.

hoice b

!nly II is correct.

hoice c

"oth I and II are correct.

hoice d

"oth I and II are incorrect.

[(] Which of the following statements are correct? I. &he long data type is the most versatile and efficient type. II. )ata type determines behavior and not si*e. hoice a !nly I is correct.

hoice b

!nly II is correct.

hoice c

"oth I and II are correct.

hoice d

"oth I and II are incorrect.

[+] Which of the following statements are correct? I. &he Java compiler chec,s all e-pressions and parameters to ensure that the types are compatible. II. In Java, we can assign a floating%point value to an integer. hoice a !nly I is correct.

hoice b

!nly II is correct.

hoice c

"oth I and II are correct.

hoice d

"oth I and II are incorrect.

[.] Which of the following statements are correct? I. boolean data type is returned by all relational operators. II. When a boolean value is output by println/ 0, 1 or 1 gets displayed. hoice a !nly I is correct.

hoice b

!nly II is correct.

hoice c

"oth I and II are correct.

hoice d

"oth I and II are incorrect.

[$] Which of the following statements are correct? I. &he type float specifies a single%precision value that uses +' bits of storage. II. Java uses 2nicode to represent characters. hoice a !nly I is correct.

hoice b

!nly II is correct.

hoice c

"oth I and II are correct.

hoice d

"oth I and II are incorrect.

[3] Which of the following statements are correct? I. In Java, variables of type int are commonly employed to control loops and to inde- arrays. II. 4ny time we have an integer e-pression involving bytes, shorts, ints and literal numbers, the entire e-pression is promoted to int before the calculation is done. hoice a !nly I is correct.

hoice b

!nly II is correct.

hoice c

"oth I and II are correct.

hoice d

"oth I and II are incorrect

[11] Which of the following statements are correct? I. In Java an int is always 5# bits regardless of the particular platform. II. Java supports unsigned, positive%only integers. hoice a !nly I is correct.

hoice b

!nly II is correct.

hoice c

"oth I and II are correct.

hoice d

"oth I and II are incorrect.

[11] Which of the following statements are correct? I. Java manages the meaning of the high%order bit by adding an unsigned right shift operator. II. &he Java run%time environment is free to use whatever si*e it wants, as long as the types behave as user declared them. hoice a !nly I is correct.

hoice b

!nly II is correct.

hoice c

"oth I and II are correct.

hoice d

"oth I and II are incorrect.

[1#] Which of the following statements are correct? I. &he simple data types are defined to have an e-plicit range and mathematical behavior. II. In Java all data types have a strictly defined range. hoice a !nly I is correct.

hoice b

!nly II is correct.

hoice c

"oth I and II are correct.

hoice d

"oth I and II are incorrect.

[15] Which of the following statements are correct? I. 6loating% point numbers are used when evaluating e-pressions that re7uire fractional precision. II. Java implements the standard set of floating%point types and operators. hoice a !nly I is correct.

hoice b

!nly II is correct.

hoice c

"oth I and II are correct.

hoice d

"oth I and II are incorrect.

[1'] Which of the following statements are correct? I. In Java octal values are denoted by a leading *ero. II. In Java, the value 13 produces an error. hoice a !nly I is correct.

hoice b

!nly II is correct

hoice c

"oth I and II are correct.

hoice d

"oth I and II are incorrect.

[1(] Which of the following statements are correct? I. In Java, an integer literal cannot be assigned to a long variable. II. &o specify a long literal, user needs to e-plicitly tell the compiler that the literal value is of type long by appending an upper or lowercase 8 to the literal. hoice a !nly I is correct.

hoice b

!nly II is correct.

hoice c

"oth I and II are correct.

hoice d

"oth I and II are incorrect.

[1+] Which of the following statements are correct? I. &he relational operators determine the relationship that one operand has to the other. II. &he relational operators determine e7uality and ordering. hoice a !nly I is correct.

hoice b

!nly II is correct.

hoice c

"oth I and II are correct.

hoice d

"oth I and II are incorrect.

[1.] Which of the following statements are correct? I. if statement is Java9s conditional branch statement. II. if statement is used to route program e-ecution through two different paths. hoice a !nly I is correct.

hoice b

!nly II is correct.

hoice c

"oth I and II are correct.

hoice d

"oth I and II are incorrect.

[1$] Which of the following is not a control instruction? hoice a )ecision statement

hoice b

ase control

hoice c

8oop control

hoice d

)eclaration statement

[ !]

Which of the following statements are correct? I. "o perform a left shift on a byte or short implies that we

m#st not $iscar$ the high-or$er bytes of the int res#lt. II. If a byte val#e is left-shifte$ that val#e will first be promote$ to int an$ then shifte$.
hoice a !nly I is correct.

hoice b

!nly II is correct.

hoice c

"oth I and II are correct.

hoice d

"oth I and II are incorrect.

[%&]

Which of the following statements are correct? I. 'ny type in Java incl#$ing integers, floating-point n#mbers, characters an$ (ooleans can be compare$ #sing the e)#ality test an$ the ine)#ality test. II. *nly boolean types can be compare$ #sing the or$ering operators.
hoice a !nly I is correct.

hoice b

!nly II is correct.

hoice c

"oth I and II are correct.

hoice d

"oth I and II are incorrect.

[#1] Which of the following statements are correct? I. 4rithmetic operators can be used on char types. II. &he minus operator has a unary form which negates its single operand. hoice a !nly I is correct.

hoice b

!nly II is correct.

hoice c

"oth I and II are correct.

hoice d

"oth I and II are incorrect.

[%%]

Which of the following statements are correct? I. In Java, the else cla#se is optional. II. if con$ition is any e+pression that ret#rns any character val#e.
hoice a !nly I is correct.

hoice b

!nly II is correct.

hoice c

"oth I and II are correct.

hoice d

"oth I and II are incorrect.

[#5] What will be the output of the code snippet given below? public class :ain ; public static void main / <tring[ ] args 0 ; double pi, r, a = r > 11.$ = pi > 5.1'1+ = a > pi ? r ? r = <ystem.out.println / a 0 = @ @
hoice a 5++.'5+##'

hoice b

5++.''

hoice c

5++.'5

hoice d

5++.'51111

[#'] What will be the output of the code snippet given below? public class :ain ;

public static void main / <tring[ ] args 0 ; char ch > #3+ = <ystem.out.println / / int 0 ch A B B A ch 0 = @ @
hoice a '1 character corresponding to it

hoice b

#3+ character corresponding to 1#$

hoice c

#3+ character corresponding to it

hoice d

'1 character corresponding to #((

#(] Which of the following statement is correct about the code snippet given below? public class :ain ; public static void main / <tring[ ] args 0 ; int bar > 1 = ; int bar > # = <ystem.out.println / bar 0 = @ @ @
hoice a &he code reports an error.

hoice b

&he code causes an e-ception

hoice c

&he code gives an output as 1.

hoice d

&he code gives an output as #.

[%,]

What will be the o#tp#t of the co$e snippet given below?

10

p#blic class -ain . p#blic static voi$ main / 0tring[ ] args 1 . $o#ble a 2 3.&, b 2 3.& 4 $o#ble c 2 -ath.s)rt / a 5 a 6 b 5 b 1 4 0ystem.o#t.println / c 1 4 7 7
hoice a (.11

hoice b

hoice c

(.1

hoice d

(.111111

What will be the o#tp#t of the co$e snippet given below? p#blic class -ain . p#blic static voi$ main / 0tring[ ] args 1 . char ch , ch% 4 ch 2 88 4 ch% 2 9:9 4 0ystem.o#t.println / ch 6 ; ; 6 ch% 1 4 7 7
hoice a CD

[%8]

hoice b

$$ D

11

hoice c

$$ $3

hoice d

C $3

[#$] Which of the following statement is correct about the code

snippet given below? public class :ain ; public static void main / <tring[ ] args 0 ; int i > '11 ? '11 E '11 = if / i >> '11 0 <ystem.out.println / BIn ifB 0 = else <ystem.out.println / BIn elseB 0 = @ @
hoice a &he code reports an error.

hoice b

&he code causes an e-ception

hoice c

&he code gives an output as In if.

hoice d

&he code gives an output as In else

[#3] Which of the following statement is correct about the code snippet given below? public class :ain ; public static void main / <tring[ ] args 0 ; double d > %11.1 E 1.1 = if / d >> )ouble.FGH4&IIGJIF6IFI&D 0

12

<ystem.out.println / d 0 = @ @
hoice a &he code reports an error.

hoice b

&he code causes an e-ception

hoice c

&he code gives an output as 1.

hoice d

&he code gives an output as %Infinity

Which of the following $eclarations are legal? [3&] I. $o#ble $ 2 .%$ 4 II. $o#ble $ 2 .%< 4 III. $o#ble $ 2 .%$= 4 I>. $o#ble $ 2 .%<= 4
hoice a !nly I and II

hoice b

!nly I and III

hoice c

!nly I, II and III

hoice d

I, II, III and II

13