Time remaining
:
:
Test Status
COREJAVARANDOMTEST
Ques 1 :
What is the meaning of the return data type void?
(A) An empty memory space is returned so that the developers can utilize it.
(B) void is not supported in Java
(C) void returns no data type.
(D) null
Ques 2 :
What is the name of the Collection interface used to represent elements in a sequence (in a particular order). Select the one correct answer.
(A) Collection
(B) Set
(C) List
(D) Map
Ques 3 :
Which operator is used to perform bitwise inversion in Java. Select the one correct answer.
(A) ~
(B) !
(C) &
(D) ^
Ques 4 :
How can you ensure that the memory allocated by an object is freed. Select the one correct answer.
(A) By invoking the free method on the object.
(B) By calling system.gc() method.
(C) By setting all references to the object to new values (say null).
(D) Garbage collection cannot be forced. The programmer cannot force the JVM to free the memory used by an object.
Ques 5 :
Which of the following statement is true about the assert statement. Select the one correct answer.
(A) If a Java class contains assert statements, then it must be compiled with -1.4 option.
(B) When a program having assertions is run, -assertion option must be specified, otherwise the assertions get ignored.
(C) A possible syntax of assert statement is assert logical_expression If logical_expression evaluates to true, the program generates an AssertionError.
(D) The program terminates on its first AssertionError.
Ques 6 :
What gets displayed on the screen when the following program is compiled and run. Select the one correct answer.
public class test {
public static void main(String args[]) {
int x,y;
x = 3 & 5;
y = 3 | 5;
System.out.println(x + " " + y);
}
}
(A) 7 1
(B) 3 7
(C) 1 7
(D) 1 3
Ques 7 :
What is the data type for the number 9.6352?
(A) float
(B) double
(C) Float
(D) Double
Ques 8 :
Which cannot directly cause a thread to stop executing?
(A) Calling the notify method on an object.
(B) Calling the start method on another Thread object.
(C) Calling a yield method.
(D) Calling wait method on an object.
Ques 9 :
What all gets printed when the following gets compiled and run. Select the three correct answers.
public class test {
public static void main(String args[]) {
int i=1, j=1;
try {
i++;
j--;
if(i/j > 1)
i++;
}
catch(ArithmeticException e) {
System.out.println(0);
}
catch(ArrayIndexOutOfBoundsException e) {
System.out.println(1);
}
catch(Exception e) {
System.out.println(2);
}
finally {
System.out.println(3);
}
System.out.println(4);
}
}
a.
0
b.
1
c.
2
d.
3
e.
4
(A) a, b, c
(B) b, c, d
(C) a, d, e
(D) a, c, d
Ques 10 :
Given the following declarations, which of the assignments given in the options below would compile. Select the two correct answers.
int i = 5;
boolean t = true;
float f = 2.3F;
double d = 2.3;
a.
t = (boolean) i;
b.
f = d;
c.
d = i;
d.
i = 5;
e.
f = 2.8;
(A) a,b
(B) b,c
(C) c,d
(D) a,d
Ques 11 :
Which of these are legal identifiers.
(A) number_1
(B) number_a
(C) $1234
(D) All of the above.
Ques 12 :
public void test(int x)
{
int odd = 1;
if(odd) /* Line 4 */
{
System.out.println("odd");
}
else
{
System.out.println("even");
}
}
Which statement is true?
(A) "odd" will always be output.
(B) "even" will always be output.
(C) Compilation fails.
(D) "odd" will be output for odd values of x, and "even" for even values.
Ques 13 :
nt index = 1;
Boolean [] test = new Boolean[3];
Boolean data = test[index];
What is the result?
(A) data has the value of true
(B) The code will not compile.
(C) data has the value of false
(D) data has the value of null
Ques 14 :
Which of these is a legal definition of a method named m assuming it throws IOException, and returns void. Also assume that the method does not take any arguments. Select the one correct answer.
(A) void m() throws IOException{}
(B) void m() throw IOException{}
(C) void m(void) throws IOException{}
(D) void m() {} throws IOException
Ques 15 :
Which of the following statements is true?
(A) The default char data type is a space( â?? â?? ) character.
(B) The default integer data type is â??longâ?? and real data type is â??floatâ??
(C) The default integer data type is â??intâ?? and real data type is â??doubleâ??
(D) The default integer data type is â??intâ?? and real data type is â??floatâ??
Ques 16 :
What all gets printed when the following program is compiled and run. Select the two correct answers.
public class test {
public static void main(String args[]) {
int i, j=1;
i = (j>1)?2:1;
switch(i) {
case 0: System.out.println(0); break;
case 1: System.out.println(1);
case 2: System.out.println(2); break;
case 3: System.out.println(3); break;
}
}
}
a.
0
b.
1
c.
2
d.
3
(A) a, b
(B) b, c
(C) c, b
(D) c, d
Ques 17 :
The initial value of an instance variable of type String that is not explicitly initialized in the program is --. Select the one correct answer.
(A) null
(B) ""
(C) NULL
(D) The instance variable must be explicitly assigned.
Ques 18 :
What gets displayed on the screen when the following program is compiled and run. Select the one correct answer.
public class test {
public static void main(String args[]) {
int x,y;
x = 1 & 7;
y = 3 ^ 6;
System.out.println(x + " " + y);
}
}
(A) 1 3
(B) 3 5
(C) 5 1
(D) 1 5
Ques 19 :
What is the number of bytes used by Java primitive long. Select the one correct answer.
(A) The number of bytes is compiler dependent.
(B) 2
(C) 4
(D) 8
Ques 20 :
A lower precision can be assigned to a higher precision value in Java. For example a byte type data can be assigned to int type.
(A) True
(B) False
Submit Answer
Don't Refresh the Page !! ...