A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

1. Which four options describe the correct default values for array elements of the types indicated?

1. int -> 0
2. String -> "null"
3. Dog -> null
4. char -> '\u0000'
5. float -> 0.0f
6. boolean -> true
a. 1, 2, 3, 4
b. 1, 3, 4, 5
c. 2, 4, 5, 6
d. 3, 4, 5, 6
View Answer Report Discuss Too Difficult!
Answer: (b).1, 3, 4, 5

2. Which one of these lists contains only Java programming language keywords?
a. class, if, void, long, Int, continue
b. goto, instanceof, native, finally, default, throws
c. try, virtual, throw, final, volatile, transient
d. strictfp, constant, super, implements, do
View Answer Report Discuss Too Difficult!
Answer: (b).goto, instanceof, native, finally, default, throws

3. Which will legally declare, construct, and initialize an array?
a. int [] myList = {"1", "2", "3"};
b. int [] myList = (5, 8, 2);
c. int myList [] [] = {4,9,7,0};
d. int myList [] = {4, 3, 7};
View Answer Report Discuss Too Difficult!
Answer: (d).int myList [] = {4, 3, 7};

4. Which is a reserved word in the Java programming language?
a. method
b. native
c. subclasses
d. reference
View Answer Report Discuss Too Difficult!
Answer: (b).native

5. Which is a valid keyword in java?
a. interface
b. string
c. Float
d. unsigned
View Answer Report Discuss Too Difficult!
Answer: (a).interface

6. Which three are valid declarations of a float?

1. float f1 = -343;
2. float f2 = 3.14;
3. float f3 = 0x12345;
4. float f4 = 42e7;
5. float f5 = 2001.0D;
6. float f6 = 2.81F;


a. 1, 2, 4
b. 2, 3, 5
c. 1, 3, 6
d. 2, 4, 6
View Answer Report Discuss Too Difficult!
Answer: (c).1, 3, 6

7. Which is a valid declarations of a String?
a. String s1 = null;
b. String s2 = 'null';
c. String s3 = (String) 'abc';
d. String s4 = (String) '\ufeed';
View Answer Report Discuss Too Difficult!
Answer: (a).String s1 = null;

8. What is the numerical range of a char?
a. -128 to 127
b. -(2^15) to (2^15) - 1
c. 0 to 32767
d. 0 to 65535
View Answer Report Discuss Too Difficult!
Answer: (d).0 to 65535

9. Which three are legal array declarations?

1. int [] myScores [];
2. char [] myChars;
3. int [6] myScores;
4. Dog myDogs [];
5. Dog myDogs [7];


a. 1, 2, 4
b. 2, 4, 5
c. 2, 3, 4
d. All are correct.
View Answer Report Discuss Too Difficult!
Answer: (a).1, 2, 4

10.

Which three piece of codes are equivalent to line 3?

1. final int k = 4;
2. public int k = 4;
3. static int k = 4;
4. abstract int k = 4;
5. volatile int k = 4;
6. protected int k = 4;
public interface Foo 
{ 
    int k = 4; /* Line 3 */
}
a. 1, 2 and 3
b. 2, 3 and 4
c. 3, 4 and 5
d. 4, 5 and 6
View Answer Report Discuss Too Difficult!
Answer: (a).1, 2 and 3

Page 1 of 3