Objective Questions
Question-1 : What will happen when you try compiling and running this code?
public class Ref{
public static void main(String argv[]){
Ref r = new Ref();
[Link](r); }
public void amethod(Ref r){
int i=99;
multi(r);
[Link](i);
}
public void multi(Ref r){
r.i = r.i*2;
}
}
1. Error at compile time
2. An output of 99
3. An output of 198
4. An error at runtime
Question-2 : What is the result of attempting to compile and run the program?
import [Link].*;
class F {
public static void main (String[] args) {
Object v = new Vector();
[Link]((v instanceof Collections)+",");
[Link]((v instanceof Arrays)+",");
[Link](v instanceof List);
}
}
1. Prints: false,false,false
2. Prints: false,false,true
3. Prints: false,true,false
4. Prints: false,true,true
5. Prints: true,false,false
Question -3: Consider the following piece of code and select all statements which yield a boolean value
of true as a result.
Double d1=new Double(10.0);
Double d2=new Double(10.0);
int x=10;
float f=10.0f;
1. d1 == d2;
2. d1 == x;
3. f == x;
4. [Link](d2);
5. None of the above
Question -4: What is the result of attempting to compile and run the following program?
class Amber {
public static void main(String[] args) {
int[][] a = {{1,2},{0,1,2},{-1,0,2}};
Object[] obj = (Object[])[Link]();
for(int i = 0;i<[Link]; i++) {
int[] ia = (int[])obj[i];
[Link](ia[i]);
}
}
}
1. Compiler error at line 3
2. Compiler error at line 6
3. Compiler error at line 7
4. Run time error
5. None of the above
Question-5 : Which of the following files is the correct name and location of deployment descriptor of a
web application. Assume that the web application is rooted at\doc-root. Select the one correct answer.
1. \doc-root\[Link]
2. \doc-root\[Link]
3. \doc-root\WEB-INF\[Link]
4. \doc-root\WEB_INF\[Link]
5. \doc-root\WEB-INF\lib\[Link]
Question-6 : A JSP page, [Link], contains only one directive:
<%@ page isErrorPage="false" errorPage="[Link]"%>
Which implicit variable is not available for [Link]?
1. Exception
2. Session
3. application
4. page
5. All of these are available
Question-7: Which of the following statements regarding HttpRequest methods are correct?
[Link] returns as Enumeration
[Link] rturns as Strings
[Link] values returns a String[]
[Link] returns an int
Question-8: Which of the following is not a standard method called as part of the JSP life cycle?
[Link]()
[Link]()
3._jspService()
[Link]()
Question-9 : What are the possible results of attempting to compile and run the program?
class A extends Thread {
public void run() {
try {sleep(10000);} catch (InterruptedException ie){}
}
public static void main(String[] args) {
A a1 = new A();
long startTime = [Link]();
[Link]();
[Link]([Link]() - startTime);
}
}
1. Prints a number greater than or equal to 0
2. The number printed must always be greater than 10000
3. This program will run for at least ten seconds
4. Compile-time error
5. Run-time error