Time remaining
:
:
Test Status
CORETEST8
Ques 1 :
At what stage in the following method does the object initially referenced by s becomes available for garbage collection. Select the one correct answer.
void method X() {
String r = new String("abc");
String s = new String("abc");
r = r+1; //1
r = null; //2
s = s + r; //3
} //4
(A) Before statement labeled 1
(B) Before statement labeled 2
(C) Before statement labeled 3
(D) Before statement labeled 4
Ques 2 :
Which of the following statements is preferred to create a string "Welcome to Java Programming"?
(A) String str = "Welcome to Java Programming"
(B) String str = new String("Welcome to Java Programming")
(C) String str; str = "Welcome to Java Programming"
(D) String str; str = new String ("Welcome to Java Programming")
Ques 3 :
What all gets printed on the standard output when the class below is compiled and executed by entering "java test lets see what happens". Select the two correct answers.
public class test
{
public static void main(String args[])
{
System.out.println(args[0]+" "+args.length);
}
}
a.
java
b.
test
c.
lets
d.
3
e.
4
f.
5
g.
6
(A) a, b
(B) c, d
(C) b, e
(D) c, e
Ques 4 :
In implementing two classes Employee and Manager, such that each Manager is an Employee, what should be the relationship between these classes. Select the one correct answer.
(A) Employee should be the base class of Manager class.
(B) Manager should be the base class of Employee class.
(C) Manager class should include the Employee class as a data member.
(D) Employee class should include Manager class as a data member.
Ques 5 :
Which all lines are part of the output when the following code is compiled and run. Select the six correct answers.
public class test
{
public static void main(String args[])
{
outer:
for(int i = 0; i < 3; i++)
{
for(int j = 3; j >= 0; j--)
{
if(i == j) continue outer;
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
m.
3 0
n.
3 1
o.
3 2
p.
3 3
(A) a, b, d, f, h, j
(B) d, g, j, k, m, n
(C) b, c, d, g, h, l
(D) c, g, h, l, n, o
Ques 6 :
String s = new String("xyz");
Assuming the above declaration, which of the following statements would compile. Select the one correct answer.
(A) s = 2 * s;
(B) int i = s[0];
(C) s = s + s;
(D) s = s >> 2;
Ques 7 :
Which of the following statements is true?
(A) A super class is a sub set of a sub class
(B) class ClassTwo extends ClassOne means ClassOne is a subclass
(C) class ClassTwo extends ClassOne means ClassTow is a super class
(D) the class Class is the super class of all other classes in Java.
Ques 8 :
What happens when the following program is compiled and run. Select the one correct answer.
public class example
{
int i = 0;
public static void main(String args[])
{
int i = 1;
i = change_i(i);
System.out.println(i);
}
public static int change_i(int i)
{
i = 2;
i *= 2;
return i;
}
}
(A) The program prints 0.
(B) The program prints 1.
(C) The program prints 2.
(D) The program prints 4.
Ques 9 :
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 10 :
Which of the following statements related to Garbage Collection are correct. Select the two correct answers.
a.
It is possible for a program to free memory at a given time.
b.
Garbage Collection feature of Java ensures that the program never runs out of memory.
c.
It is possible for a program to make an object available for Garbage Collection.
d.
The finalize method of an object is invoked before garbage collection is performed on the object.
(A) a, b
(B) b, d
(C) c, d
(D) b, c
Ques 11 :
What kind of thread is the Garbage collector thread is?
(A) Non daemon thread
(B) Daemon thread
(C) Thread with dead state
(D) None of the above
Ques 12 :
What happens when the following program is compiled and run. Select the one correct answer.
public class example
{
int i = 0;
public static void main(String args[])
{
int i = 1;
change_i(i);
System.out.println(i);
}
public static void change_i(int i)
{
i = 2;
i *= 2;
}
}
(A) The program prints 0.
(B) The program prints 2.
(C) The program prints 1.
(D) The program prints 4.
Ques 13 :
What should be done to invoke the run() method on a thread for an object derived from the Thread class. Select the one correct answer.
(A) The run() method should be directly invoked on the Object.
(B) The start() method should be directly invoked on the Object.
(C) The init() method should be directly invoked on the Object.
(D) The creation of the object using the new operator would create a new thread and invoke its run() method.
Ques 14 :
If a base class has a method defined as
void method() { }
Which of the following are legal prototypes in a derived class of this class. Select the two correct answers.
a.
void method() { }
b.
int method() { return 0;}
c.
void method(int i) { }
d.
private void method() { }
(A) b, c
(B) a, d
(C) a, c
(D) b, d
Ques 15 :
In which all cases does an exception gets generated. Select the two correct answers.
int i = 0, j = 1;
a.
if((i == 0) || (j/i == 1))
b.
if((i == 0) | (j/i == 1))
c.
if((i != 0) && (j/i == 1))
d.
if((i != 0) & (j/i == 1))
(A) a, c
(B) b, c
(C) b, d
(D) a, d
Ques 16 :
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 17 :
What happens when the following program is compiled and run. Select the one correct answer.
public class example
{
int i[] = {0};
public static void main(String args[])
{
int i[] = {1};
change_i(i);
System.out.println(i[0]);
}
public static void change_i(int i[])
{
i[0] = 2;
i[0] *= 2;
}
}
(A) The program prints 0
(B) The program prints 1.
(C) The program prints 2
(D) The program prints 4.
Ques 18 :
What is the default priority of a newly created thread.?
(A) MIN_PRIORITY (which is defined as 1 in the Thread class.)
(B) NORM_PRIORITY (which is defined as 5 in the Thread class.)
(C) MAX_PRIORITY (which is defined as 10 in the Thread class.)
(D) A thread inherits the priority of its parent thread.
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 keyword when applied on a method indicates that only one thread should execute the method at a time. Select the one correct answer.
(A) transient
(B) volatile
(C) synchronized
(D) native
Submit Answer
Don't Refresh the Page !! ...