0% found this document useful (0 votes)
55 views3 pages

Objective Questions

The document contains 9 multiple choice questions related to Java programming concepts. The questions cover topics like object references, inheritance, arrays, threads, JSP, servlets and more. For each question, 5 possible answers are provided and the programmer must select the right answer.

Uploaded by

keerthi karthee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views3 pages

Objective Questions

The document contains 9 multiple choice questions related to Java programming concepts. The questions cover topics like object references, inheritance, arrays, threads, JSP, servlets and more. For each question, 5 possible answers are provided and the programmer must select the right answer.

Uploaded by

keerthi karthee
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

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();
          r.amethod(r);     }
     public void amethod(Ref r){
          int i=99;
          multi(r);
          System.out.println(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 java.util.*;
class F {
     public static void main (String[] args) {
          Object v = new Vector();
          System.out.print((v instanceof Collections)+",");
          System.out.print((v instanceof Arrays)+",");
          System.out.print(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. d1.equals(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[])a.clone();
           for(int i = 0;i<obj.length; i++) {
                int[] ia = (int[])obj[i];
                System.out.print(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\dd.xml
2. \doc-root\web.xml
3. \doc-root\WEB-INF\web.xml
4. \doc-root\WEB_INF\dd.xml
5. \doc-root\WEB-INF\lib\dd.xml

Question-6 : A JSP page, test.jsp, contains only one directive:


<%@ page isErrorPage="false" errorPage="error.jsp"%>
Which implicit variable is not available for test.jsp?

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?

1.getHeaderNames returns as Enumeration

2.getHeaders rturns as Strings

3.getheader values returns a String[]

4.getIntParameter returns an int

Question-8:   Which of the following is not a standard method called as part of the JSP life cycle?

1.jspInit()

2.JspService()

3._jspService()

4.jspDestory()

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 = System.currentTimeMillis();
          a1.start();
          System.out.print(System.currentTimeMillis() - 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

You might also like