Sunteți pe pagina 1din 12

[1] Which of the following statements are correct? I. In Java octal values a re 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. In Java an int is alwa ys 32 bits regardless of the particular platform. II. Java supports unsigned, po sitive-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.

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

[4] Which of the following statements are correct? I. The simple dat a 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.

[5] 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 tim e we have an integer expression involving bytes, shorts, ints and literal number s, 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.

[6] Which of the following statements are correct? I. The type float specifi es 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.

[7] 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 l ogical 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.

[8] Which of the following statements are correct? I. Java manages t he 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.

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

[10] 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. 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. boolean data type is r eturned by all relational operators. II. When a boolean value is output by print ln( ), 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.

[12] Which of the following statements are correct? I. In Java, a byt e 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.

[13] Which of the following statements are correct? I. The Java compi ler checks all expressions and parameters to ensure that the types are compatibl e. 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.

[14] Which of the following statements are correct? I. Integer litera ls 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. 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 in teger literal cannot be assigned to a long variable. II. To specify a long liter al, 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.

[16] Which of the following statements are correct? I. For each left shift, the high-order bit is shifted out and lost and a zero is brought in on th e left. II. When a left shift is applied to an int operand, bits are lost once t hey are shifted past bit position 63. 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 is not a control instruction?

Choice a Decision statement Choice b Case control Choice c Loop control Choice d Declaration statement

[18] Which of the following selection statements are supported by Jav a? 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

[19] Which of the following statements are correct? I. When the divis ion 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 floa ting-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.

[20] Which of the following statements are correct? I. Any type in Java inclu ding integers, floating-point numbers, characters and Booleans can be compared u sing the equality test and the inequality test. II. Only boolean types can be co mpared using the ordering 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.

[21] Which of the following statements are correct? I. In Java, the e lse clause is optional. II. if condition is any expression that returns any char

acter 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.

[22] Which of the following statements are correct? I. if statement i s Java s conditional branch statement. II. if statement is used to route program e xecution through two different paths. 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.

[23] Which of the following statement is correct about the code snippet given below? public class Main { public static void main ( String[ ] args ) { int i = 400 * 400 / 400 ; if ( i == 400 ) System.out.println ( "In if" ) ; else System.out.println ( "In else" ) ; } } Choice a The code reports an error. Choice b The code causes an exception

Choice c The code gives an output as In if. Choice d The code gives an output as In else

[24]

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

[25]

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 Choice b 366.44

Choice c 366.43 Choice d 366.430000

[26] Which of the following statement is correct about the code snippet given below? public class Main { 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.

[27]

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

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

[28]

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

public class Main { public static void main ( String[ ] args ) { int x ; x = 10 ; if ( x == 10 ) { int y = 20 ; System.out.println ( x + " " + y ) ; x = y * 2 ; } System.out.println ( x ) ; } } Choice a 10 20 10 Choice b 10 20 40 Choice c 40 20 40 Choice d 20 20 10

[29] Which of the following statement is correct about the code snipp et given below? public class Main { public static void main ( String[ ] args ) { char ch = 'a' ;

ch = ( int ) ch ; System.out.println ( ch ) ; } } Choice a The code reports an error. Choice b The code causes an exception. Choice c The code gives an output as 97 Choice d The code gives an output as a.

[30]

Which of the following declarations are legal?

I. double d = 1.2d ; II. double d = 1.2D ; III. double d = 1.2d5 ; IV. double d = 1.2D5 ; Choice a Only I and II Choice b Only I and III Choice c Only I, II and III Choice d I, II, III and IV

S-ar putea să vă placă și