1. Question frm localization in struts,
ii. Entire specification is done.....
iii. Creates specific resource for each request
a. Either i or ii
2. Neither i nor ii
3. Only i
4. Only ii
2. what will happen when init() is called?
3. To specify an ActionMapping to use when a request doesn't match any other mapping, you can
Use an asterisk for the path property
Set the “default” property of the mapping to true
Set the “unknown” property of the mapping to true
Set the “missing” init-param of the ActionServlet to the mapping’s path.
4. jsp tag libs
5. Given some coding using tag interfaces …….. Asked me to debug it.
6. JSP flow………. Don’t take it easy question it will be very confusing I don’t remember the options
7. Jsp declarations syntax
8. Read carefully the following topics:
redirect and forward
IN command in SQL
Got one question regarding sub queries in SQL
Coding regarding type casting in java ( implicit type casting)
Javax.servlet and javax.servlet.pagecontext packages.
9. Difference Between <%@Include %> and <jsp=include>
Ans: <%@Include %> - related to compile time
<jsp=include> - related with request time
10. Which two are equal
Ans: <jsp:scriplet>---------;</jsp:scriplet> and <%--------;%>
11. what method used to initiate servlet
Ans: void init(ServletConfig)
12. When to use forward and when to use redirect.
Ans: redirect – client side -- forward server side
13. How to maintain sessions:
Ans: save in secret field,url rewriting,cookies … In short All of the above ;)
14. What identifies in an action uniquely..?
Ans: path
15. In init parameter
Ans: Application
16. In MVC perspective , struts provides ..?
Ans: Controller
17. Initial attribute values can be set from deployment descriptor.
Ans False
18. Arrays in java are objects
19. Relating to implicit objects
1. using forward in jsp
2. redirect and forward in servlet
3. servlet context
4. jsp in relation to servlet
5. For shopping cart which will you prefer?
n. application
o. session
p. page
q. request
answer: session
6. send redirect on request obj is sent to the browser...
a. true
b. false
7. Question frm localization in struts,
i) Entire specification is done.....
ii) Creates specific resource for each request
a. Either i or ii
b. Neither i nor ii
c. Only i
d. Only ii
8. Difference Between <%@Include %> and <jsp=include>
Ans: <%@Include %> - related to compile time
<jsp=include> - related with request time
9. Which two are equal
Ans: <jsp:scriplet>---------;</jsp:scriplet> and <%--------;%>
10. what method used to initiate servlet
Ans: void init(ServletConfig)
11. When to use forward and when to use redirect.
Ans: redirect – client side -- forward server side
12. How to maintain sessions:
Ans: save in secret field,url rewriting,cookies … In short All of the above ;)
13. What identifies in an action uniquely..?
Ans: path
14. In init parameter
Ans: Application
15. In MVC perspective , struts provides ..?
Ans: Controller
16. Initial attribute values can be set from deployment descriptor.
Ans False
17. what’s the output…?
<html>
<body>
Value is
<%= ” ” %>
</body></html> Ans: value is
18. Relating to implicit objects
19. What represents an identifier name for a resource but not have to locate/path to it ..?
Ans: URI
20. what are the methods in HTTP?
1. GET
2. HEAD
3. RETRIEVE
4. POST
21. What is the output of the following?
<@ page language="java">
out.print("Hello");
out.print("World")
etc (I don't remember it exactly)
22. Advantages of jsp…. Separation of presentation logic from business logic so that few people can work on presentation and others can work on the other logic..
1) Which of the following types of inheritances do java support?
a.single inheritance
b.multiple inheritance
c.multilevel inheritance
d.hybrid
e.Only single and multiple inheritance
Ans: single and multilevel
2.) import library.*
Public class Myprogram{}
What should be the name of the java file containing this program?
a.Library.java
Ans: b.Myprogram.java
3.) which of the following are the valid comment stmt in java?
a.//
b./**/
c.!---!
d./** **/
Ans: a,b,d
4)An object should never directly manipulate the internal data of another object.
This reflects which of the following..
a.encapsulation
b.abstraction
c.polymorphism
d.inheritance
Ans: encapsulation
5) public final void amethod(){
Sysout(“amethod”);
Public class Fin extends Base{
Public static void main(String args[]){
Base b=new Base();
b.amethod();}}
Wt is the o/p
a.compile time error caused because final methods must be declared as final itself
b.Compile time error because cannot inherit from a cls with final methods.
c.Runtime error because base is not defined as final.
d.amethod is printed.
I feel the question is wrong….
Maybe the question is
class B{
public final void amethod(){
System.out.println("amethod");
}
}
public class A extends B{
public static void main(String args[]){
A a =new A();
a.amethod();
B b=new B();
b.amethod();
}
}
Then “amethod” is printed twice
5.) class A{
Static void m(){
Sysout(“A”);}}
Class B extends A{
Static void m(){
Sysout(“B”)}}
Class C extends B{
Static void m(){
Sysout(“C”);}}
Class D{
Public static void main(String[] args)
{
C c=new C();
c.m();
B b=c;
b.m();}}
wt s de o/p?
a.AAA
b.ABC
c.CBA
d.CCC
clue: static methods cant be overridden but can be redefined
6.) Base class has a method, void method(){}
Which are legal prototypes in a derived cls of this cls.
a.void method(){}
b.int method(){return 0;}
c.void method(int i){}
d.private void method(){}
Ans:a,c
7.)import java.util.*
Public class Problem
{
Public static void main(String[] args){
Timer timer=new Timer();
Timer.schedule(new TimerTask){
Public void run(){
Sysout(“Exiting”);
Timer.cancel();}}
Sysout(“In 5 sec this appln will exit”);
What will u do to make it compile?
a.Add final infront of the declaration of time variable.
b.A nested class declared within a method has accesss to any final,local variables in scope.
c.Change the ‘s’ in the last Sysout to ‘S’.
d.Change the return type in the public void run method to int.
8.) Which is responsible for java’s platform independent
a.JRE
b.JVM
c.JavaAPI
d.javap
Ans:b
9.)class MyBase{
Public MyBase(int i){}}
Public class Myover extends MyBase{
Public static void main(String args[]){
Myover m=new Myover(10);}
Myover(int i){
Super(i);}
Myover(String s,int i){
This(i);}}
Which could be in include in the Myover(String s,int i) method?
a.Myover m=new Myover();
b.super();
c.this(“Hello”,10)
d.MyBase b=new MyBase(10)
Ans: d
10.)Name the access modifier which when used with a method,makes it available to all the classes in the same package and to all the sub classes of the class?
a.protected
b.private
c.public
d.default
11.)Which are true?
a.Java does not supports inheritance through pointers.
b.java supports classes but does not support structure,union
c.java supports multiple inheritance.
d. to some extent the interface feature provides the desirable features of multiple inheritance to a java program.
12.) import java.io.*
Class Base{
Public void amethod() throws FileNotFoundException{}}
Public class ExcepDemo extends Base{
Public static void main(String argv[]){
ExcepDemo e=new ExcepDemo();}
Public void amethod(){}
Protected ExcepDemo(){
Try{
DatInputStream din= new DataInputSream(system.in);
Sysout(“passing’)
Din.readByte();
Sysout(“couting”);
This.amethod();}
Catch(IO Exception ioe){}}}
Wt s de o/p
a.compile time error due to protected constructor.
b.Compile time error due to method not declared exception
c.Runtime error due to amethod not dec.. exeption
d.compile and run with o/p of passing and continuing
13.)sub class methods can access superclass members /attributes at all time
a.True
b.False
14.) class A{
Public int getNumber(int a){
Return a+1;}}
Class B extends A{
Public int getNumber(int a){
Return a+2;}
Public static void main(S args[]){
A a= new A();
Sysout(a.getNumber(0));}
Ans:1
1. How to make servlet implement single thread model.
Ans: By setting isThreadsafe=False
<%@ page isThreadSafe="false" %>
2. Difference Between <%@Include %> and <jsp=include>
Ans: <%@Include %> - related to compile time
3. <jsp=include> - related with request time
4. Which two are equal
Ans: <jsp:scriplet>---------;</jsp:scriplet> and <%--------;%>
5. what method used to initiate servlet
Ans: void init(ServletConfig)
6. When to use forward and when to use redirect.
Ans: redirect – client side -- forward server side
7. How to maintain sessions:
Ans: save in secret field,url rewriting,cookies … In short All of the above ;)
8. What identifies in an action uniquely..?
Ans: path
9. In init parameter ………..
Ans:Application
10. In MVC perspective , struts provides ..?
Ans: Controller
11. If methods in older versions of java are used then what happens ..?
Ans: deprecated
12. Initial attribute values can be set from deployment descriptor.
Ans False
13. Relating to implicit objects
14. What represents an identifier name for a resource but not have to locate/path to it ..?
Ans:URI
15) Question on the syntax of the setting a property name in JSP
16) What is the output of the following
<HTML><BODY>The output is <%=“”%></BODY></HTML>
Ans: The output is
What ever is inside the “” will be printed.
17) flow how a jsp works when it gets a request..refer above
get the request, check for the servlet, if servlet present ....
19) About implicit variable
i)cant be used in bean and servlet
ii)can be used in jsp
20) which is the least valid in jsp?
i) request
ii) page
iii) application
iv)session
21) ways to input a value...? which of teh following is true?
<set-property..>
<init-property..>
22) Are doGet doPost service methods thread safe Answer :No
23) given an connection prog asked abt
1. password should be encrypted
2. driver name url wrong
3. incorrect sequence access,
4…………….
24) no of objects created
Thing a1,a2;
a1=new
Thing a2=new
25) using forward in jsp
26) redirect and forward in servlets
27) servlet context
28) jsp in relation to servlet
29) if the package name is not known
30) send redirect on request obj is sent to the browser...
a.true
b.false
31) Question frm localization in struts,
i) Entire specification is done.....
ii) Creates specific resource for each request
a. Either i or ii
b. Neither i nor ii
c. Only i
d. Only ii (not sure)
Localization or L10n on the other hand, is the process of customizing your application to support a specific location. When you customize your web application to a specific country say, Germany, you are localizing your application. Localization involves establishing on-line information to support a specific language or region. Though I18n and L10n appear to be at odds with each other, in reality they are closely linked.
1) Which are true regarding class defined in an interface
its not possible in java
all classes are public
all classes are static
methods defined in interface can be called with in the class
2) what does _server flag in J2SE 1.3 specify………
3) what is a process………some options
4) can you call sendRedirect method on response object after response is sent away
Answer : NO
sendRedirect(String):
sendRedirect method of response object is used to send a redirect response to the client temporarily by making use of redirect location URL given in parameter. Thus the sendRedirect method of the response object enables one to forward a request to a new target. But one must note that if the JSP executing has already sent page content to the client, then the sendRedirect() method of response object will not work and will fail.
General syntax of sendRedirect of response object is as follows:
response.sendRedirect(String) |
In the above the URL is given as string.
For example:
response.sendRedirect("http://xxx.test.com/error.html"); |
5) if the access modifier of the overridden method is protected, what could be the access modifiers for the over riding method?
a)public
b)protected
c)private
d)default
ans: a,b
6) u defined an NotAllowedException on your own and which of the following snippet will throw the exception?
Only one one option will be having the throws clause for the method.
7)how will u make ur own transaction?
a)transaction.getcommit(Boolean )
b)transaction.setautocommit()
c)transaction.commit()
8)when a page in a jsp is modifie which of the following could happen?
a)request processing happens before translation phase.
b)translation phase occurs before request processing phase.
C)translation phase doesn’t occur.
d)none of the above.
As long as the JSP page remains unchanged, any subsequent request goes straight to the request processing phase (i.e., the container simply executes the class file). When the JSP page is modified, it goes through the translation phase again before entering the request processing phase.
9)int i=10;
i>>=10;
sysout(i);
Ans:0
10) Question about unchecked exceptions….
Options are like whether it is runtime exception are compile time exceptions.
11)Question about File not found exception and IO exception..which inherits which one?
Options are true or false….
12) public class A {
public static void main(String [] args){
String name1 = "java"; String name2 = "java";
System.out.println(name1==name2);}}Ans:true
13)What is true about Arrays
1)arrays index starts from 1 and ends upto size.
2)arrays in java are objects.
3)we cant assign one array to another…
4)other option I don’t remember.
14)Which of the following methods are there?(CheckBox)
1)request.getusername
2)request.getCurrentSession
3)request.getQueryString
4)request.getheader
Ans:3 and 4
15)for session to be disabled what is the valid method?
1)session.setMaxinactiveinterval(-1)
2)session. setMaxinactiveinterval(MAX_INT)
3)remaining two options are not correct…
Answer is either of these two options.
16)Question about Vector and Arraylist.
17)question on redirect and forward…..which stores previous history?
Answer : forward
In simple words we say
1. response.sendRedirect takes full round trip ie goes to the browser and comes back to the server where as forward is server to server transfer
2. response.sendRedirect makes a new request so all previous request parameters are lost and in order to persist the data you need to send through query string where as in forward the old request is forwarded so all old request data persist
78.What is the output of the following?
<@ page language="java">
out.print("Hello");
out.print("World")
etc (I don't remember it exactly)
79. Advantages of jsp…. Separation of presentation logic from business logic so that few people can work on presentation and others can work on the other logic.
80. A question on ActionServlet
81. Flow of JSP
loading->compiled->generate response
if not loaded->compiled->again load->generate response
82. public class sample{
psvm{ sysout(“100”+10);}}
ANS: 10010
83. Taglib descriptor……….
a. TLD is coded in Java
84. Application resources……………….
b. application
c. application resources
d. resources
e. methods
85. J2SE 3.1………………..
f. Hot spot……………..
The Java HotSpot Virtual Machine is a core component of the Java SE platform. It implements the Java Virtual Machine Specification, and is delivered as a shared library in the Java Runtime Environment. As the Java bytecode execution engine, it provides Java runtime facilities, such as thread and object synchronization, on a variety of operating systems and architectures. It includes dynamic compilers that adaptively compile Java bytecodes into optimized machine instructions and efficiently manages the Java heap using garbage collectors, optimized for both low pause time and throughput. It provides data and information to profiling, monitoring and debugging tools and applications.
HotSpot is an "ergonomic" JVM. Based upon the platform configuration, it will select a compiler, Java heap configuration, and garbage collector that produce good to excellent performance for most applications. Under special circumstances, however, specific tuning may be required to get the best possible performance. The resources collected here will help the reader understand and tune the Java HotSpot Virtual Machine.
86. Redirect and forward
87. JSP vs. Servlets
88. Action form in servlet
89. Action class is called by………………..
g. name
h. page
i. path
90. java bean syntax
j. <java: id, name, value>
k. <java: name, value>
l. <java: id, value>
91. sessions…………
92. Which method is not available in servlet config? –refer above
m. getServletContext()
n. getInitParameter()
o. gerInitParameterNames()
p. addInitParameter()
93. Format of path specified in HTML:
q. GET/………./index.html1.1/HTTP
r. GET/………./index.html HTTP/1.1
s. GET ………./index.html1.1/HTTP
94. To read data which is superior?
t. input stream
u. file reader
95. Reset in HTML?
96. What is reason for separating business logic and presentation in JSP?
97. What is the tag to make output of a jsp to appear in the output of another jsp?
98. How can struts populate a form in struts 1.1?
99. xml page can be created using jsp. (T/F)
100. Various phases in jsp container?
101. Jsp supports multithreading? . options are like this:
a) by default it will support multithreading (not sure)
b) never supports
c) partially supports
d) none
JSP documents are ultimately compiled to servlets, which are multi-threaded by default and are assumed to be thread-safe. If the code in your JSP is not thread-safe, you can request the container uses a single threaded execution of the resulting servlet using the page directive <%@ page isThreadSafe="false" %>.
In this case the container may create multiple instances of the JSP servlet to handle concurrent requests or use synchronization to control access to a single instance. Both approaches are likely to reduce the performance of the page because of the overheads of instantiation and locking respectively, so this directive should be used with caution.
102. Struts is based on which design pattern? Answer : MVC
New questions added
1) A question on Hash map and Hash table…
2) Type 1 driver is… JDBC-ODBC
3) Advantages of jsp…. Seperation of presentation logic from business logic so that few people can work on presentation and others can work on the other logic..
4) A question on database connectivity… codes given in all the four options.. only in one of them a connection is closed in finally block.. that’s the answer.
5) Which is faster..
1 Left to right join in increasing order
2 Right to left join in decreasing order
3 Left to right in decreasing order
4 Right to left in increasing order.
6) Which is better…. Composition of new classes or Creation of subclasses.
7) A question on ActionServlet
8) What type does ‘Class.forName()’ return?
The priority for these are below in increasing order of their scope in JSP page:
1. page
2. request
3. session
4. aplication
Is the JDBC-ODBC Bridge multi-threaded?
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.
Does JSP support multi-threading?
Refer http://www.codestyle.org/java/servlets/faq-JSP.shtml#jspmultithreading
1. select avg(column)
column
20
null
10
0
2. Output of the following:
i=1
do{
i--;}
while(i>2)
sop("i");
3. not valid array declaration(check box)
i)string [][]a;
ii)string []i[];
iii)string [5][];
iV)sting [0][]b;
4. if there are 10 value and 5 null values in a row select count(row) prints?
i) 10
ii)15
iii) null
5. flow how a jsp works when it gets a request..
get the request, check for the servlet, if servlet present
6. 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 exception
7. when using join in sql which of the following is fast to load..
i) in increasing order from right to left
ii) in descending order from right to left
iii) in increasing order from left to right
iv) in descending order from left to right
8. Truncate command deletes the table true or false
9. given an connection prog asked abt
1. password should be encrypted
2. driver name url wrong
3. incorrect sequence retrival
4…………….
10. jdbc:odbc driver supports multi threading..
a. true b. False
11. Name of application resource file is set by the servlet init_param named.
a. application resources
b. application
c. resources
d. messages
12. 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.**
13. Stuts populate a form in struts 1.1?
e. By overriding populate bean method of Action Mapping.
f. By overriding populate method of Action Form
g. By overriding process populate method of Request process
h. All the above
14. Which is not an HTTp method
i. Retrieve
j. Post
k. Head
l. Get
15. <html><body>The value of <%=” “%>…what will print
16. Union will select distinct values say true or false
17. Options true while subclassing
18.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”/>
19. Jsp supports multithreading or not . options are like this:
a. fully supports
b. never supports
c. partially supports
d. none
20. Which is used to identify the resource but not tell how to reach that resource?
a. URI
b. URL
c. URI or URL
d. URN
21. What do you have to do to make an instance variable into a JavaBean property?
a. Declare the instance variable public and static.
b. Define a get method and a set method for the variable.
c. Drop the Bean into the BeanBox property sheet.
22. From a MVC perspective, Struts provides the
a. model
b. view
c. controller
23.What is a benefit of using JavaBeans to separate business logic from presentation markup within the JSP environment?
a. It allows the JSP to access middleware.
b. It creates a cleaner role separation between the web-production team and the software development team, so that the web-production team can focus on presentation markup, while the software team can focus on building reusable software components for helping to generate dynamic displays.
c. It provides a dynamic markup environment, such that JavaBeans are integrated seamlessly with the template presentation content, in order to create the dynamic display for the client.
d. It provides the developer with full access to the Java 2 Platform Enterprise Edition (J2EE), which is unavailable from outside the JavaBean environment.
24. How to disable a session
a. use session.disable().
b. session cant be disabled.
c. give some property of session as false in some tag…..
d. ……..
25. what is the output?
Public class class1 {
Public void method1(int a, int b)
{
SOP(a+” “+b)
}
Public static void main(){
Class1 c=new class1()
Int x=10;
c.method1(x,x=5)
}
}
a. 10 10
b. 10 5
c. 10 20
d. None