Tuesday, January 12, 2010

java7

II. Each Question Carries 2 Mark.

1) class Hello
{ public static void main(String args[])
{
System.out.println(“Hello”);
}
}
a) Hello b) Compile error c) runtime error d) None

2) char ch = ‘A’;
char dy;
dy = ch++;
System.out.println(dy);

a) A b) B c) C d) D

3) byte b = 50;
b = b * 2;
System.out.println(b);

a) Error b) 100 c) 50 d) None

4) byte b = 50;
b = (byte) (b * 2);
System.out.println(b);

a)100 b) Error c) 50 d) None

5) Is this declaration correct
i) int months[] = new int [12]; ii) int [] months = new int[12];

a. Both are true b) only i is true c) only ii is true d) None

6) double d = 42.3;
System.out.println(“d mod 10 = “+ x % 10);
a) 2.3 b) 2 c) 0.3 d) None

7) int d = 42;
System.out.println(“d mod 10 = “+ x % 10);
a) 2 b) 4 c) 0 d) None

8) int a = 32;
a = a>>2;
What is the value of a ?

a) 8 b) 4 c) 16 d) 32

9) int a[] = {1,2,3,4,5,6,7,8,9};
System.out.println(a.length);

a) 9 b) 8 c) 10 d) None

10) Which of the following is not a valid comment in java
a) /* comments / b) /** comments hers*/
c) //comments here d) /*comments here*/


II. Answer – 2 Mark.


1. A 2. A 3. A 4. A 5. A 6. D 7. B
8. A 9. A 10. A