Time remaining
:
:
Test Status
CORETEST2
Ques 1 :
Which methods can access to private attributes of a class?
(A) Only Static methods of the same class
(B) Only instances of the same class
(C) Only methods those defined in the same class
(D) Only classes available in the same package.
Ques 2 :
Which of these are not legal identifiers. Select the four correct answers.
a.
1alpha
b.
_abcd
c.
xy+abc
d.
transient
e.
account-num
f.
very_long_name
(A) a, c, e
(B) a, c, d, e
(C) c, d, e, f
(D) all of above
Ques 3 :
Is the following statement true or false. The constructor of a class must not have a return type.
(A) true
(B) false
Ques 4 :
What is an aggregate object?
(A) An object with only primitive attributes
(B) An instance of a class which has only static methods
(C) An instance which has other objects
(D) None of the above
Ques 5 :
Which of the following are keywords in Java. Select the two correct answers.
a.
friend
b.
NULL
c.
implement
d.
synchronized
e.
throws
(A) d, e
(B) a, b
(C) a, b, c
(D) all of above
Ques 6 :
What gets printed when the following program is compiled and run? Select the one correct answer.
class test {
public static void main(String args[]) {
int i;
do {
i++;
}
while(i < 0);
System.out.println(i);
}
}
(A) The program does not compile as i is not initialized.
(B) The program compiles but does not run.
(C) The program compiles and runs but does not print anything.
(D) The program prints 0.
Ques 7 :
Which of these are interfaces in the collection framework. Select the two correct answers.
a.
Set
b.
List
c.
Array
d.
Vector
e.
LinkedList
(A) a,b,c
(B) a,b
(C) b,c,d,e
(D) c,d
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 :
What happens when the following code is compiled and run. Select the one correct answer.
for(int i = 1; i < 3; i++)
for(int j = 3; j >= 1; 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 10 :
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 11 :
A top level class may have only the following access modifier. Select the one correct answer.
(A) package
(B) protected
(C) private
(D) public
Ques 12 :
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 13 :
Assume that File is an abstract class and has toFile() method. ImageFile and BinaryFile are concrete classes of the abstract class File.
Also, assume that the method toFile() is implemented in both Binary File and Image File. A File references an ImageFile object in memory and the toFile method is called, which implementation method will be called?
(A) Binary File
(B) Image File
(C) Both File and Binary Files
(D) None of the above
Ques 14 :
Which of the following are Java keywords. Select the four correct answers.
a.
super
b.
strictfp
c.
void
d.
synchronize
e.
instanceof
(A) a, b
(B) a, b, c, e.
(C) b, c, d
(D) a, c, d, e
Ques 15 :
What gets printed when the following program is compiled and run? Select the one correct answer.
class xyz {
static int i;
public static void main(String args[]) {
while (i < 0) {
i--;
}
System.out.println(i);
}
}
(A) The program does not compile as i is not initialized.
(B) The program compiles but does not run.
(C) The program compiles and runs but does not print anything.
(D) The program prints 0.
Ques 16 :
Which of these are interfaces in the collection framework. Select the two correct answers.
a.
HashMap
b.
ArrayList
c.
Collection
d.
SortedMap
e.
TreeMap
(A) a,b
(B) c,d
(C) d,e
(D) a,d
Ques 17 :
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 18 :
What gets printed on the standard output when the class below is compiled and executed. Select the one correct answer.
public class ShortCkt {
public static void main(String args[]) {
int i = 0;
boolean t = true;
boolean f = false, b;
b = (t || ((i++) == 0));
b = (f || ((i+=2) > 0));
System.out.println(i);
}
}
(A) 0
(B) 1
(C) 2
(D) 3
Ques 19 :
What gets printed when the following program is compiled and run. Select the one correct answer.
class test {
public static void main(String args[]) {
int i,j,k,l=0;
k = l++;
j = ++k;
i = j++;
System.out.println(i);
}
}
(A) 0
(B) 1
(C) 2
(D) 3
Ques 20 :
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
Submit Answer
Don't Refresh the Page !! ...