17th december 11/6 3


1)         Name of application resource file is set by the servlet init_param named.

a.         application resources
b.         application
c.         resources
d.         messages
Ans:b

2)         Roles of Resultset

a.         Used in while loop to iterate through the resultset.
b.         Resultset object maintains a cursor pointing to its current row of data.
c.         Initially cursor in first row, the next method moves the cursor to next row because it returns false when there are no more rows in the Resultset object
d.         All the above.
Ans:b

3)         20
            0
            NULL
            10     
What is the average of this column
Ans:10

4)         when we join two or more table in query which can be easily loaded
a.         ascending from left to right
b.         descending from left to right
c.         ascending from right to left
d.         descending from left to right
Ans:a

5)         union will select distinct values say true or false Ans:true

6)         advantage of preparedStatement: Ans:Precompiled

7)         Various scope in JSP

a.         application
b.         session
c.         request
d.         page
Ans:all




8)         If you have created a custom Action Mapping subclass with the property “service”, you can initialize the value to “select Record” using which

a.         All the below
b.         <init prop name=”service” value=”select Record”/>
c.         <set prop property=”service” value=”select Record”/>
d.         <put field key=”service” value=”select Record”/>
Ans:c

9) 10 not null values 5 null values what will give count(name)
Ans:10

10)  service(),doPost(),doGet() are thread safe?true or false
Ans:false
1)Can be made thread safe by implementing SingleThreadModel interface.This tells the container to make the methods thread safe.
2)Synchronised block can also be used.


11)       Latest version of JSP ?
 Ans :- 2.1

12)       Methods in cloneable interface?
 Ans:- no methods are declared in Cloneable interface

13)       How can you return the number of records in a table?
Ans:-select count(*) from <table name>

14)       which is not true about Tag Library Descriptor(TLD)

15)       union will select distinct values say true or false
Ans:true

16)       Type 1 driver is also known as?
Ans:jdbcodbc driver

17)       A) var NoofRows = 1;
            B) var NoofRows = 100;
for(i=0;i< NoofRows;i++){
INSERT INTO SOMETABLE VALUES(SOMECOLUMN)
}
Stmt.execute();

a) Same time.
b) B little longer than A
c) A takes 100 times B
d)cant be determinedAns:a


18)  public class A {
                        A(){
                                    class B{
                                                void method(){
                                                            System.out.println("No arg");
                                                }
                                    }
                        }
                        A(int i){
                                    class B{
                                                void method(){
                                                            System.out.println("arg");
                                                }
                                    new B();
                                    }
                        }
            class C(){
                        public static void main(String[] args) {
                                    A obj=new A(1);
                        }
}

a)wont compile
b)compiles but will throw runtime error
c)will be compiled and executed successfully
d)two separate class files will be generated for two inner class definitions.
Ans:c

19) which of the following will throw Arithmatic exception
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==1)&(j/i==1))
Ans:b,c,d
Note:a single | also works same as ||(logical OR) as seen here.

20) Can we write xml in jsp.
            1) static pages
            2) dynamic pages
            3) both static and dynamic
            4) no xml tags are supported only HTML tags are supported
Ans:3

21)what is the benefits of SQL prepared statement
      a) they are not compiled
      b) they are pre-complied
      c) they are post-compiled
      d) none of the above   Ans:b

22) which are all the valid methods in jsp??

    a) -JSPInit()
       _JSPService()
       _JspDestroy()

    b) _JSPInit()
       _JSPService()

    c)  -JSPInit()
       _JSPService()
       _JspDestroy()
       _JSPdodelete()
       _JSPdoget()
       _JSPdopost()
Ans:a

23)How do we get information from the servlet if the information is in the folder web-inf/asd.zip
          Here config =>servletconfig and context =>servletcontext
a)config.getresourceasstream(/web.inf/asd.zip)
          b)config.inputstream(“asd.zip”);
          c)context.inputstream(“asd.zip”);
          d) context.getresourceasstream(/web.inf/asd.zip)
Ans:d

24)what does struts provide in MVC architecture?
          a)model
          b)view
          c)controller
          d)none of the above
Ans:c

25) There will be three codes for jdbc connection which of the three is valid?
i)in the code.. finally{con.close}
ii) con.close inside try
Ans:i)

26)if a and b are 2 non negative integers and str is a String. Then how many characters does str.substring(a,b) return?
          a)a+b
          b)b-a
          c)a-b
          d)b-a+1
Ans:b

27)check the code
          int i = 0;
          Boolean flag = false;
          If(flag && ( i++ <10){
          }
          System.out.println(i);
What would be the output of the code?
          a)0
          b)10
          c)9
          d)none of the above

28)what would be the output of the following JSP code
          <%@page language = java %>
          <html><body>
          Out.println(“Hello”);
          Out.println(“world”);
          </body></html>

          a)Hello world
          b) compiler error
          c) runtime error
          d)none of the above
Ans-b

29)How would you manage ur transactions?
          a)connection.getcommit();
          b)connection.gettransactioncommit();
          c)connection.getNewcommit();
          d)connection.setAutocommit();
Ans:d

30)what would be the output of the following code
          Class A{
                   Static void printp1(){System.out.println(“P1”);}
                   Void printp2(){System.out.println(“P2”);}
                   Void printp1p2(){
                   Printp1();
                   Printp2();
}
}
Class B extends class A{
          Static void printp1(){System.out.println(“Q1”);}
          Void printp2(){System.out.println(“Q2”);}
          Public static void main(String args[]){
          New B().printp1p2();
}
}

a)p1p2
b)q1q2
c)p1q2
d)p1q1

31)what are the primitive data types in java?
            a)Float
          b)String
          c)char
          d)byte

32)what are permissible main() method declarations allowed in java?
            a)public static void main(String args[]){
            b)public static void main(String []args){
          c)public static void main(){
          d)public static void main(int i){

33)Inner join selects all nonmatching elements. True or false

34)difference between <jsp: > and <% @include: > directives

35)can we use the other constructers in a class having multiple constructers in defining constructers? True or false

36)what are the sub tags of <servlet> in a web.xml
          a)mapping
          b)url
          c)context
          d)
37)how do we log the in a servlet

38)An action in struts are uniquely defined by
          a)path
          b)parameter
          c)etc…






39) What are true about constructors:
a)    They can be overloaded.
b)    They can be overridden as they are not inherited.
c)    They cant be overridden as they  are not inherited
d)    They can both be overridden and overloaded.

40) What is correct procedure :
a)      <servlet-name>abcd</servlet-name>
<servlet-class>com.cts.abcd</servlet-class>
b)      blab la bla

41) What is the correct sequence of JSP execution.

42) what is correct as per sun coding standard:
Int abcd;pqrst;
Or
Int abcd;
Int pqrst;

43) what is correct as per sun coding standard:
a) Package COM.CTS.PACKAGE1
      b) Package com.CTS.PACKAGE1
      c)  Package com.cts.package1 Ans:c

44) What is a JDBC driver?

45) Steps for connecting with the database

46) What’s true from following?
a) Final methods can be overridden.
b) Final methods can’t be overridden
Ans:b

47) Difference between <jsp:include> and the directive include

48) <@ page isErrorPage=”true”> --- indicates what?
Ans:the current page is an error page and it also provides an implicit exception object.

49) Difference between send redirect and forward.

50) which of the following http methods don’t cache data
a) PUT
b) HEAD
c) GET
d) POST

51) <bean:write> has a “filter” attribute.what does it signify?

52) Find out what is Hotspot

53) What is unchecked exception?

54) What is not true about TLD?
            a) It is a java code
            b) It stores info about all tags
Ans-a

55) How to prevent a session from being destroyed?
            a) session.setTimeOut(-1)
            b) session.setMaxInactiveInterval(-1)
            c) session.setMaxInactiveInterval(MAX_INTERVAL)
ans-b

56) How do you disable session in jsp?

57) Servlet url is given.In  service() there is a call to getRequestPath().What will be returned?

58) How many instances are there of ServletContext when awe are dealing with multiple JVMs?

59) What does <bean:write> tag do?

60) What kind of exception does read() of Inputstream throw?
            a) FileNotFound
            b) IO Exception Ans-b
           
61) When an exception is thrown the control can be of many forms.In what case the code inside the block will be part of control flow

62) public class A{

public static void main(String[] args){
int i=10 ;
i>>=10;
System.out.println(i);
}
}

What is the output

Ans 0…right shift for 10 times

63) VALID IDENTIFIER IN JAVA
a.       java
b.      #abc
c.       %bnmn
d.      $nmn

Ans a, d

64) What is the valid child of the root <web-apps> in the deployment descriptor?
a. <servlet-mapping>
b. <context-mapping>
c. <mime-mapping>
d. <url-pattern>
Ans-a

65) Benefit of using Java Beans to separate Business Logic from presentation markup within the JSP environment
a. It allows JSP to access middleware

66) What happens when a JSP page is modified
a. It goes to the translation phase and then request processing phase
b. It goes to the translation phase.
c. It goes to the request processing phase.
d. It goes to the request processing phase and then translation phase

67) What is the relation between JSP and Servlet
a. JSP is built on servlet semantics and compiled to sevlet
b They are not useful in combination
c. Servlet is built on jsp semantics and compiled to JSp
Ans:a


68) Annoymous inner class can be declared by implementing interface and extending class. True or false
Ans: false

69) How do you manage your own transaction?
Ans: connection.setAutoCommit(false)

70) When does the JVM exist?It was a multiple choice question.

71) How is Priamry key different from Unique key?
Ans: Contrary to PRIMARY key UNIQUE constraints can accept NULL but just once. If the constraint is defined in a combination of fields, then every field can accept NULL and can have some values on them, as long as the combination values is unique.



72) Can JSP technology be used to generate xml files?
Ans:yes

73) How can JSP data be shared across many pages?
a) request object
b) servletcontext(application object)
Ans:b

74) JSP Technology is used in which type(s) of application?
a) Web application
b) Client / Server
Ans-a,b

75) JSP implicit objects are
a) Programmatically accessed by javabean and servlet
b) They are not present
c) They are already instantiated
Ans:c(if it is a radio button)
If checkbox:-Ans-a,c(application object of jsp can be accessed thru getServletContext() in servlet class.

76) In database connection scriplet
Select a,b,c from tablename
Resultset rs;
Integer i = rs.getInt(c);
String s=rs.getString(b);
Float f=rs.getFlost(a);

What is wrong in the code for retrieval of data

a) The order of retrieval is not correct.
b) Primitive type is being returned.
Ans:b

77) If catch order is changed for FilNotFoundException and IOException then is code affected? True/False
Ans:True,code is affected as FilNotFoundException inherits IOException.


78) What is the output of the following codes...

class A{
            public void func(int i){
                        System.out.println("Inside func of return type void");
            }
            public int func(int j){
                        System.out.println("Inside func of return type int");
            }
}

class B extends A{
            A a = new A();
            a.func(5);
}

a)Inside func of return type void
b)Inside func of return type int
c)Compile time error
d)Run time error.
Ans:c



79)jdbc driver supports multithreading?
Ans:false……………………not sure