Time remaining
:
:
Test Status
COREJAVARANDOMTEST
Ques 1 :
What is returned when the method substring(2, 4) is invoked on the string "example"? Include the answer in quotes as the result is of type String.
(A) "xa"
(B) "am"
(C) "xm"
(D) "xamp"
Ques 2 :
How many bytes are used to represent the primitive data type int in Java. Select the one correct answer.
(A) 2
(B) 4
(C) 8
(D) 1
Ques 3 :
Which of these are legal identifiers. Select the three correct answers.
a.
number_1
b.
number_a
c.
$1234
d.
-volatile
(A) a, b, c
(B) a, b
(C) a
(D) b
Ques 4 :
Select the one correct answer. The number of characters in an object of a class String is given by
(A) The member variable called size
(B) The member variable called length
(C) The method size() returns the number of characters.
(D) The method length() returns the number of characters.
Ques 5 :
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
Ques 6 :
Which expression can be used to access the last element of an array. Select the one correct answer.
(A) array[array.length]
(B) array[array.length - 1]
(C) array[array.length() - 1]
(D) array[array.length()]
Ques 7 :
Write down the modifier of a method that makes the method available to all classes in the same package and to all the subclasses of this class.
(A) public
(B) protected
(C) private
(D) default
Ques 8 :
Which of the following are legal declaration and definition of a method. Select all correct answers.
a.
void method() {};
b.
void method(void) {};
c.
method() {};
d.
method(void) {};
e.
void method {};
(A) a,b
(B) a
(C) a,b,c
(D) b,d,e
Ques 9 :
Which of the following is a Java keyword. Select the four correct answers.
a.
extern
b.
synchronized
c.
volatile
d.
friend
e.
friendly
f.
transient
g.
this
h.
then
(A) b, c
(B) b, c, f, g
(C) e, g, h
(D) all of above.
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[]) {
boolean x = false;
int a;
if(x) a = x ? 1: 2;
else a = x ? 3: 4;
System.out.println(a);
}
}
(A) 1
(B) 2
(C) 3
(D) 4
Ques 11 :
What all gets printed when the following gets compiled and run. Select the two correct answers.
public class test {
public static void main(String args[]) {
String s1 = "abc";
String s2 = new String("abc");
if(s1 == s2)
System.out.println(1);
else
System.out.println(2);
if(s1.equals(s2))
System.out.println(3);
else
System.out.println(4);
}
}
(A) 1 3
(B) 1 4
(C) 2 3
(D) 2 4
Ques 12 :
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 13 :
What happens when the following code is compiled and run. Select the one correct answer.
for(int i = 1; i < 4; i++)
for(int j = 1; j < 4; j++)
if(i < j)
assert i!=j : i;
(A) The class compiles and runs, but does not print anything.
(B) The number 1 gets printed with AssertionError
(C) The number 2 gets printed with AssertionError
(D) The number 3 gets printed with AssertionError
Ques 14 :
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 15 :
What are the things we have to follow while creating annotations?
(A) methods must not have any throws clauses
(B) methods must not have any parameters
(C) method should return any one of primitive data types
(D) All the above
Ques 16 :
Which of the following is considered as a blue print that defines the variables and methods common to all of its objects of a specific kind?
(A) Object
(B) Class
(C) Method
(D) Real data types
Ques 17 :
By using which modifier we can prevent from overridden?
(A) final
(B) static
(C) we cant prevent
(D) by default it provides
Ques 18 :
What gets printed when the following code is compiled and run. Select the one correct answer.
public class test {
public static void main(String args[]) {
int i = 1;
do {
i--;
} while (i > 2);
System.out.println(i);
}
}
(A) 0
(B) 1
(C) 2
(D) -1
Ques 19 :
Which of the following statements are true. Select the two correct answers.
a.
The wait method defined in the Thread class, can be used to convert a thread from Running state to Waiting state.
b.
The wait(), notify(), and notifyAll() methods must be executed in synchronized code.
c.
The notify() and notifyAll() methods can be used to signal and move waiting threads to ready-to-run state.
d.
The Thread class is an abstract class.
(A) a, c
(B) a, d
(C) b, c
(D) c, d
Ques 20 :
Which of these are legal array declarations or definitions?
(A) int[] []x[];
(B) int x[5];
(C) int *x;
(D) None of above
Submit Answer
Don't Refresh the Page !! ...