Globallogic Technical Question Paper
Globallogic Technical Question Paper
What is the output of the following code when compiled and run? Select two correct answers.
System.out.println(y+","+x+","+z); //line 3
A. Prints 0,1,1
C. Prints 0,0,1
https://www.freshersnow.com/
E. Error during compilation at line 2
A. The garbage collection thread cannot outlive the last user thread.
D. The finalize() method is invoked at most once by the JVM for any given object.
E. The finalize() method may resurrect the object upon which it has been invoked.
What is the output of the following code when compiled and run? Select one correct answer.
import java.io.*;
try{
https://www.freshersnow.com/
myref.test();
}catch(IOException ioe){}
System.out.println("In Question05");
System.out.println("In Question05Sub");
https://www.freshersnow.com/
A. Prints:
In Question05Sub
B. Prints:
In Question05
C. Prints:
In Question05
In Question05Sub
D. Prints:
In Question05Sub
In Question05
class A{}
https://www.freshersnow.com/
class B extends A implements E{} //line 1
interface E{}
E e = (E)a; //line 4
B b = (B)e; //line 5
https://www.freshersnow.com/
B. Compilation error on line 1 because interface E is not yet declared (forward-referencing).
How many objects are eligible for garbage collection immediately after line 1? Select one
correct answer.
q08.doSomething(); //line 1
Thread.sleep(20000);
https://www.freshersnow.com/
for(int i=0;i
A. 0
B. 1
C. 2
D. 3
E. 4
What is the output of the following code when compiled and run? Select one correct answer.
https://www.freshersnow.com/
try {
int i = (int)(Math.random()*10);
if(i<=5)
System.out.println("i = "+i);
else
System.err.println(e.getMessage()+" (i="+i+")");
B. Compilation error.
https://www.freshersnow.com/
C. An exception is thrown at runtime.
D. Output is i = 2
What is the output of the following code when compiled and run? Select one correct answer.
new Question10().doSomething();
int i=5;
for(int j=0;j<=i;j++){
https://www.freshersnow.com/
System.out.print(" "+j);
});
t.start();
A. Prints 0 1 2 3 4
B. Compilation error.
C. No output.
E. Prints 0 1 2 3 4 5
What is the output of the following code when compiled and run? Select one correct answer.
https://www.freshersnow.com/
public class Question11 {
addSomeStuff(buf1);
System.out.println(buf1.toString());
StringBuffer b = buf.replace(6,10,"orld");
System.out.println(b.delete(0,1).toString());
A. Prints
Hello World
https://www.freshersnow.com/
Hello World
B. Prints
Hello orld
Hello orld
C. Prints
Hello orld
ello orld
D. Prints
ello orld
ello orld
E. Compilation error.
What is the output of the following code when compiled and run? Select two correct answers.
(Note: when an instance of a Vector is printed, its content appear between square brackets [])
import java.util.*;
https://www.freshersnow.com/
public class Question13 {
col.add(new Integer(1));
col.add(new Integer("2"));
col.add(col.elementAt(1));
col.setElementAt(col.elementAt(2),0);
System.out.println(col);
https://www.freshersnow.com/
C. The code compiles and runs fine.
https://www.freshersnow.com/