You are on page 1of 12

1) a. b. c. d. 2) a. b. c. d.

3)

Name of application resource file is set by the servlet init_param named. application resources application resources messages Roles of Resultset Used in while loop to iterate through the resultset. Resultset object maintains a cursor pointing to its current row of data. 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 All the above.

20 0 NULL 10 What is the average of this column 4) a. b. c. d. 5) 6) 7) a. b. c. d. when we join two or more table in query which can be easily loaded ascending from left to right descending from left to right ascending from right to left descending from left to right union will select distinct values say true or false advantage of preparedStatement precompiled. Various scope in JSP application session request page

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. b. c. d. All the below <init prop name=service value=select Record/> <set prop property=service value=select Record/> <put field key=service value=select Record/>

9) 10 not null values 5 null values what will give count(name) 10 ( Answer : Count(*) =15 and Count(row) = 10 ) 10) service(),doPost(),doGet() are thread safe?true or false 11) 12) Latest version of JSP ? Ans :- 2.1 Methods in cloneable interface? Ans:- 1

13) How can you return the number of records in a table? Ans:-select count(*) from <table name> 14) 15) 16) 17) which is not true about Tag Library Descriptor(TLD) union will select distinct values say true or false Type 1 driver is also known as? JDBC-ODBC Driver 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 determined 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. 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)) 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 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 22) which are all the valid methods in jsp?? a) -JSPInit() _JSPService() _JspDestroy() b) _JSPInit() _JSPService() c) -JSPInit() _JSPService() _JspDestroy() _JSPdodelete() _JSPdoget() _JSPdopost() 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) Confusion on these two. 24)what does struts provide in MVC architecture? a)model b)view c)controller d)none of the above 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 iii) con.close inside finally 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 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 29)How would you manage ur transactions? a)connection.getcommit(); b)connection.gettransactioncommit(); c)connection.getNewcommit(); d)connection.setAutocommit(); 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);}

} } 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

Void printp1p2(){ Printp1(); Printp2();

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

What is the correct sequence of JSP execution. Ans: JSP Lifecycle: Translation Phase: JSP Page will be converted to Servlet Compilation Phase: The resulting servlet is compiled. Instantiate and loading Phase: Instance will be created for the servlet ands it loaded to memory. Call jspinit():Perform Initialization process. Call _jspService(): this will be called upon each request. Call jspDestroy(): the instance will be destroyed when not needed any more.
41)

will be

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 44) What is a JDBC driver? 45) Steps for connecting with the database 46) Whats true from following? a) Final methods can be overridden. b) Final methods cant be overridden 47) Difference between <jsp:include> and the directive include Ans: jsp:include tag includes the jsp during runtime

48) <@ page isErrorPage=true> --- indicates what? Error has been happened. The page is the errorpage 49) Difference between send redirect and forward. Ans: sendRedirect always sends a header back to the client/browser 50) which of the following http methods dont cache data a) PUT b) HEAD c) GET d) POST
51) <bean:write> has a filter attribute.what does it signify? Ans: refer to Struts dovetail Questions Doc 52) Find out what is Hotspot Ans: HotSpot is the primary Java Virtual Machine for desktops and servers produced by Sun Microsystems. It features techniques such as just-in-time compilation and adaptive optimization designed to improve performance. 53) What is unchecked exception? Ans: A unchecked exception is an programming language exception that need not be caught. As such, the compiler does no check to see if it is handled at compile time. 54) What is not true about TLD?

a) It is a java code b) It stores info about all tags


55) How to prevent a session from being destroyed?

a) session.setTimeOut(-1) b) session.setMaxInactiveInterval(-1) c) session.setMaxInactiveInterval(MAX_INTERVAL) 56) How do you disable session in jsp? Ans: <%@ page session="false" %> 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? Ans: one servlet one servletcontext per jvm

59) What does <bean:write> tag do? Ans: refer to Struts Dovetail Question 60) What kind of exception does read() of Inputstream throw? a) FileNotFound b) IO Exception 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 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> 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

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. Ans: The JVM shuts down in two circumstances: 1) You call System.exit(n); 2) All threads not marked "daemon" end. 71) How is Priamry key different from Unique key? Ans : Unique key can contain only one null value. 72) Can JSP technology be used to generate xml files?Yes 73) How can JSP data be shared across many pages? a) request object b) servletcontext(application object) 74) JSP Technology is used in which type(s) of application? a) Web application b) Client / Service 75) JSP implicit objects are a) Programmatically accessed by javabean and servlet b) They are not present c) They are already instantiated If radio button then c otherwise a,b 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. 77) If catch order is changed for FilNotFound and I/O exception then code is affected or not? True/False 78) jdbc-odbc driver supports multithreading or not? Ans; No. The JDBC-ODBC Bridge does not support concurrent access from different
threads. The JDBC-ODBC Bridge uses synchronized methods to serialize all of the calls that it makes to ODBC. Multi-threaded Java programs may use the Bridge, but they won't get the advantages of multi-threading. In addition, deadlocks can occur between locks held in the database and the semaphore used by the Bridge. We are thinking about removing the synchronized methods in the future. They were added originally to make things simple for folks writing Java programs that use a single-threaded ODBC driver.

Also refer http://java.sun.com/products/jdbc/faq.html#14

79) which command retrives from the database Ans:select 80) what is given in class.forname in a jdbc file? i) class object of the driver manager ii)super class of driver manager Ans: class object of the driver manager 81) When JDBC connection object would released Ans: when close() method is called on the connection object 82) What if the Java driver is not compatible with the JDBC? Ans: exception is thrown at runtime 83) driver manager is used to a)manage all connections. b)to manage jdbc drivers Ans: manage connections and mange jdbc drivers
84) If connection is not fully compliant what happens? Ans: Driver Manager wont register it.

85) What is the fastest database driver among typeI,II,III,IV drivers? Ans: Type IV

86) In a JNDI environment, through which class does one acquire a connection to a specific data source?--E A. Driver B. DriverManager C. Connection D. DatabaseMetaData E. DataSource

87) In a non-JNDI environment, through which class does one acquire a connection to a specific data source?--B A. B. C. D. E. Driver DriverManager Connection DatabaseMetaData Context

88) What does JDBC stand for? --B A. B. Java Database Connectivity JDBC is not an acronym

89) Which of the following ways will not load a JDBC driver?--D A. B. C. D. Configure the list of drivers in the jdbc.driver system property Call the driver's constructor Pass the class name to the forName method of Class Use JNDI to locate the Driver

90) Which class contains the transaction control methods setAutoCommit, commit, and
rollback?

A. B.

Connection Statement

C.

ResultSet

Answer (A): Transactions are controlled at the Connection level. See: Trans actions.

You might also like