Time remaining
:
:
Test Status
COREJAVARANDOMTEST
Ques 1 :
By which class we can read object from stream?
(A) Reader
(B) ObjectInputStream
(C) ObjectReader
(D) File
Ques 2 :
What gets displayed on the screen when the following program is compiled and run. Select the one correct answer.
protected class example {
public static void main(String args[]) {
String test = "abc";
test = test + test;
System.out.println(test);
}
}
(A) The class does not compile because the top level class cannot be protected.
(B) The program prints "abc"
(C) The program prints "abcabc"
(D) The program does not compile because statement "test = test + test" is illegal.
Ques 3 :
When a thread terminates its processing, into what state that thread enters?
(A) Dead state
(B) Waiting state
(C) Running state
(D) Beginning state
Ques 4 :
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 5 :
Which of the following is not a return type?
(A) boolean
(B) void
(C) public
(D) Button
Ques 6 :
Which all lines are part of the output when the following code is compiled and run. Select the nine correct answers.
public class test {
public static void main(String args[]) {
for(int i = 0; i < 3; i++) {
for(int j = 3; j >= 0; j--) {
if(i == j) continue;
System.out.println(i + " " + j);
}
}
}
}
a.
0 0
b.
0 1
c.
0 2
d.
0 3
e.
1 0
f.
1 1
g.
1 2
h.
1 3
i.
2 0
j.
2 1
k.
2 2
l.
2 3
(A) a, b, c, d, e, i, j, k, l
(B) b, c, d, e, g, h, i, j, l
(C) b, c, e, j, k, l, f, h, i
(D) c, d, e, f, g, h, i
Ques 7 :
Select the one most appropriate answer. What is the purpose of method parseInt defined in Integer class.
(A) The method converts an integer to a String.
(B) The method is used to convert String to an integer, assuming that the String represents an integer.
(C) The method is used to convert String to Integer class, assuming that the String represents an integer.
(D) The method converts the Integer object to a String.
Ques 8 :
Which statement is true for the Class java.util.HashSet?
(A) The elements in the collection are unique.
(B) The collection is guaranteed to be immutable
(C) The elements in the collection are ordered.
(D) The elements in the collection are synchronized.
Ques 9 :
What happens when the following class is compiled and run. Select one correct answer.
public class test
{
public static void main(String args[])
{
int x = 0, y = 1, z;
if(x)
z = 0;
else
z = 1;
if(y)
z = 2;
else
z = 3;
System.out.println(z);
}
}
(A) The program prints 1
(B) The program prints 2
(C) The program prints 3
(D) The program does not compile because of problems in the if statement.
Ques 10 :
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;
x = -3 >> 1;
x = x >>> 2;
x = x << 1;
System.out.println(x);
}
}
(A) 7
(B) 23
(C) 5
(D) 2147483646
Ques 11 :
Which of the assignment are not valid.
(A) short s = 28;
(B) float f = 2.3;
(C) double d = 2.3;
(D) int I = '1';
Ques 12 :
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 13 :
If result = 2 + 3 * 5, what is the value and type of â??resultâ?? variable?
(A) 17, byte
(B) 25, byte
(C) 17, int
(D) 25, int
Ques 14 :
Which statement is true?
(A) ArrayList is a sub class of Vector
(B) HashTable is a sub class of Dictionary
(C) LinkedList is a subclass of ArrayList
(D) Vector is a subclass of Stack
Ques 15 :
Is the following statement true or false. The constructor of a class must not have a return type.
(A) true
(B) false
Ques 16 :
What is the name of collection interface used to maintain unique elements.
(A) List
(B) Set
(C) Map
(D) All of above
Ques 17 :
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 18 :
What will be the output of the program?
public class X
{
public static void main(String [] args)
{
try
{
badMethod();
System.out.print("A");
}
catch (Exception ex)
{
System.out.print("B");
}
finally
{
System.out.print("C");
}
System.out.print("D");
}
public static void badMethod()
{
throw new Error(); /* Line 22 */
}
}
(A) BC is printed before exiting with an error
(B) Compilation fails.
(C) ABCD
(D) C is printed before exiting with an error message.
Ques 19 :
A program needs to store the name, salary, and age of employees in years. Which of the following data types should be used to create the Employee class. Select the three correct answers.
a.
char
b.
boolean
c.
Boolean
d.
String
e.
int
f.
double
(A) a,d,f
(B) a,e,f
(C) d,e,f
(D) d,a,e
Ques 20 :
Which of these statements are legal. Select the three correct answers.
a.
int arr[][] = new int[5][5];
b.
int []arr[] = new int[5][5];
c.
int[][] arr = new int[5][5];
d.
int[] arr = new int[5][];
e.
int[] arr = new int[][5];
(A) a, b
(B) a, b, c
(C) a, b, c, d
(D) a, b, c, d, e
Submit Answer
Don't Refresh the Page !! ...