j2ee mock.doc

13

Click here to load reader

Upload: sayedmohseen123

Post on 16-Apr-2015

295 views

Category:

Documents


0 download

DESCRIPTION

mock test

TRANSCRIPT

Page 1: j2ee mock.doc

[30]

Which of the following statement is correct about the code snippet given below?

public class Main {public static void main ( String[ ] args ) {double d = -10.0 / 0.0 ;if ( d == Double.NEGATIVE_INFINITY )System.out.println ( d ) ;}}

 Choice a The code reports an error.

 Choice b The code causes an exception

 Choice c The code gives an output as 0.

 Choice d The code gives an output as -Infinity

[29]

Which of the following declarations are legal?

I.    char c = 0x1234 ; II.    char c = \u1234 ;III.    char c = '\u1234' ;

 Choice a Only I

 Choice b Only III

 Choice c Only I and III

 Choice d I, II and III

[28]

What will be the output of the code snippet given below?

public class Main { public static void main ( String[ ] args ) {double pi, r, a ;r = 10.8 ;pi = 3.1416 ;a = pi * r * r ; System.out.println ( a ) ;}}

 Choice a 366.436224

Page 2: j2ee mock.doc

 Choice b 366.44

 Choice c 366.43

 Choice d 366.430000

[27]

What will be the output of the code snippet given below?

public class Main {public static void main ( String[ ] args ) {double a = 3.0, b = 4.0 ;double c = Math.sqrt ( a * a + b * b ) ;System.out.println ( c ) ;}}

 Choice a 5.00

 Choice b 5

 Choice c 5.0

 Choice d 5.000000

 

[26]

What will be the output of the code snippet given below?

public class Main {public static void main ( String[ ] args ) {char ch = 296 ;    System.out.println ( ( int ) ch + " " + ch ) ;}}

 Choice a 40 character corresponding to it

 Choice b 296 character corresponding to 128

 Choice c 296 character corresponding to it

 Choice d 40 character corresponding to 255

[25]

Which of the following statement is correct about the code snippet given below?

public class Main

Page 3: j2ee mock.doc

{public static void main ( String[ ] args ) {int bar = 1 ;{ int bar = 2 ; System.out.println ( bar ) ;}}}

 Choice a The code reports an error.

 Choice b The code causes an exception

 Choice c The code gives an output as 1.

 Choice d The code gives an output as 2.

[24]

What will be the output of the code snippet given below?

public class Main {public static void main ( String[ ] args ) {boolean b ;b = false ;b = true ;if ( b ) System.out.println ( "This is executed." ) ;b = false ;if ( b ) System.out.println ( "This is not executed." ) ;System.out.println ( 10 > 9 ) ;}}

 Choice a This is not executed.false

 Choice b This is executed.1

 Choice c This is executed.true

 Choice d This is not executed.0

[23]

What will be the output of the code snippet given below?

Page 4: j2ee mock.doc

public class Main {public static void main ( String[ ] args ) {char z = 'A' + 55 ;System.out.print ( z ) ; }}

 Choice a W

 Choice b x

 Choice c y

 Choice d z

[22]

Which of the following selection statements are supported by Java? I. if II. switch III. Macro

 Choice a Only I and II

 Choice b Only I and III

 Choice c Only II and III

 Choice d I, II and III

[21] Which of the following statements are correct? I. Nested if else statements are not allowed in java. II. if statements are executed from top to down.

 Choice a Only I is correct.

 Choice b Only II is correct.

 Choice c Both I and II are correct.

 Choice d Both I and II are incorrect.

 

[20]

Which of the following statements are correct? I. To perform a left shift on a byte or short implies that we must not discard the high-order bytes of the int result. II. If a byte value is left-shifted that value will first be promoted to int and then shifted.

 Choice a Only I is correct.

 Choice b Only II is correct.

Page 5: j2ee mock.doc

 Choice c Both I and II are correct.

 Choice d Both I and II are incorrect.

[19] Which of the following statements are correct? I. In Java, the else clause is optional. II. if condition is any expression that returns any character value.     

 Choice a Only I is correct.

 Choice b Only II is correct.

 Choice c Both I and II are correct.

 Choice d Both I and II are incorrect.

[18] Which of the following statements are correct? I. Arithmetic operators can be used on char types. II. The minus operator has a unary form which negates its single operand.     

 Choice a Only I is correct.

 Choice b Only II is correct.

 Choice c Both I and II are correct.

 Choice d Both I and II are incorrect.

[17] Which of the following statements are correct? I. if statement is Java’s conditional branch statement. II. if statement is used to route program execution through two different paths.

 Choice a Only I is correct.

Page 6: j2ee mock.doc

 Choice b Only II is correct.

 Choice c Both I and II are correct.

 Choice d Both I and II are incorrect.

[16] Which of the following statements are correct? I. When the division operator is applied to an integer type, there will be a fractional component attached to the result. II. In Java, modulus operator cannot be applied to floating-point types.

 Choice a Only I is correct.

 Choice b Only II is correct.

 Choice c Both I and II are correct.

 Choice d Both I and II are incorrect.

[15] Which of the following statements are correct? I. In Java, an integer literal cannot be assigned to a long variable. II. To specify a long literal, user needs to explicitly tell the compiler that the literal value is of type long by appending an upper or lowercase L to the literal.

 Choice a Only I is correct.

 Choice b Only II is correct.

 Choice c Both I and II are correct.

 Choice d Both I and II are incorrect.

[14] 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.

 Choice a Only I is correct.

 Choice b Only II is correct.

 Choice c Both I and II are correct.

 Choice d Both I and II are incorrect.

Page 7: j2ee mock.doc

[13] Which of the following statements are correct? I. The type float specifies a single-precision value that uses 64 bits of storage. II. Java uses Unicode to represent characters.

 Choice a Only I is correct.

 Choice b Only II is correct.

 Choice c Both I and II are correct.

 Choice d Both I and II are incorrect.

[12] Which of the following statements are correct? I. In Java an int is always 32 bits regardless of the particular platform. II. Java supports unsigned, positive-only integers.     

 Choice a Only I is correct.

 Choice b Only II is correct.

 Choice c Both I and II are correct.

 Choice d Both I and II are incorrect.

[11] Which of the following statements are correct? I. The Java compiler checks all expressions and parameters to ensure that the types are compatible. II. In Java, we can assign a floating-point value to an integer.

 Choice a Only I is correct.

 Choice b Only II is correct.

 Choice c Both I and II are correct.

 Choice d Both I and II are incorrect.

[10] Which of the following statements are correct? I. In Java, char is 8-bit type. II. We have negative chars in Java.

 Choice a Only I is correct.

 Choice b Only II is correct.

 Choice c Both I and II are correct.

 Choice d Both I and II are incorrect.

Page 8: j2ee mock.doc

[9] 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( ), 1 or 0 gets displayed.

 Choice a

Only I is correct.

 Choice b

Only II is correct.

 Choice c

Both I and II are correct.

 Choice d

Both I and II are incorrect.

[8] Which of the following statements are correct? I. In Java, variables of type int are commonly employed to control loops and to index arrays. II. Any time we have an integer expression involving bytes, shorts, ints and literal numbers, the entire expression is promoted to int before the calculation is done.

 Choice a Only I is correct.

 Choice b Only II is correct.

 Choice c Both I and II are correct.

 Choice d Both I and II are incorrect.

[7] Which of the following statements are correct? I. The simple data types are defined to have an explicit range and mathematical behavior. II. In Java all data types have a strictly defined range.

 Choice a

Only I is correct.

 Choice b

Only II is correct.

 Choice c

Both I and II are correct.

 Choice d

Both I and II are incorrect.

[6] Which of the following statements are correct? I. The long data type is the most versatile and efficient type. II. Data type determines behavior and not size.

Page 9: j2ee mock.doc

 Choice a Only I is correct.

 Choice b Only II is correct.

 Choice c Both I and II are correct.

 Choice d Both I and II are incorrect.

[5] Which of the following statements are correct? I. Floating-point numbers are used when evaluating expressions that require fractional precision. II. Java implements the standard set of floating-point types and operators.

 Choice a Only I is correct.

 Choice b Only II is correct.

 Choice c Both I and II are correct.

 Choice d Both I and II are incorrect.

[4] 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. The Java run-time environment is free to use whatever size it wants, as long as the types behave as user declared them.

 Choice a Only I is correct.

 Choice b Only II is correct.

 Choice c Both I and II are correct.

 Choice d Both I and II are incorrect.

[3] Which of the following statements are correct? I. In Java octal values are denoted by a leading zero. II. In Java, the value 09 produces an error.

 Choice a Only I is correct.

 Choice b Only II is correct

 Choice c Both I and II are correct.

 Choice d Both I and II are incorrect.

 

[2] 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

Page 10: j2ee mock.doc

of the target type.

 Choice a Only I is correct.

 Choice b Only II is correct.

 Choice c Both I and II are correct.

 Choice d Both I and II are incorrect.

 

[1] Which of the following statements are correct? I. In Java, a byte is a signed 8-bit type entity. II. The smallest integer data type is short.     

 Choice a Only I is correct.

 Choice b Only II is correct.

 Choice c Both I and II are correct.

 Choice d Both I and II are incorrect.