0% found this document useful (0 votes)
92 views6 pages

Final

The document provides 20 questions related to Java, Spring, JSP, Servlets, and JDBC. The questions cover topics like Spring configuration, JSP implicit objects, HTTP session tracking mechanisms, ResultSet types, SQL execution methods, and connection creation methods. The correct answers are provided for each multiple choice question.

Uploaded by

swapna jr
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)
92 views6 pages

Final

The document provides 20 questions related to Java, Spring, JSP, Servlets, and JDBC. The questions cover topics like Spring configuration, JSP implicit objects, HTTP session tracking mechanisms, ResultSet types, SQL execution methods, and connection creation methods. The correct answers are provided for each multiple choice question.

Uploaded by

swapna jr
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/ 6

Java Questions

===========
1.public class Bran{
public static void main(String args[]){
new Barn( ).go("hi",1);
new Barn( ).go("hi","world",2);
}
public void go(String... y,int x){
System.out.print(y[y.length-1]+" ");
}
}
What is the result
1.hi hi
2.hi world
3.world world
4.Compilation fails

Ans:4

2.public class Test{


public static void main(String[] args){
int x = 5;
boolean b1 = true;
boolean b2 = false;
if((x==4)&& !b2)
System.out.print("1");
System.out.print("2");
if((b2=true)&&b1)
System.out.print("3");
}
}

What is the result


1. 2
2. 3
3. 1 2
4. 2 3

Ans:4
3. class Atom{
Atom(){System.out.print("atom");}
}
class Rock extends Atom{
Rock(String type){System.out.println(type);}
}
public class Mountain extends Rock{
Mountain(){
super("granite");
new Rock("granite");
}
public static void main(String[] a){new Mountain( );}
}
what is the resul
What is the result
1. Compilation fails
2. atom granite
3. granite granite
4. atom granite atom granite
Ans:4

4.Given the Spring configuration file which are the correct statements
<bean class
="com.spring.service.BankServiceImpl"p:bankName="NationalBank">
</bean>
1. the P namespace has to be declared
2. Bean id is bankServiceImpl
3. The BankServiceImpl refernces a NationalBank bean
ANS:1
5.Given the following Spring Configuration file what is the Correct answer
<bean class="com.spring.service.MyserviceImpl">
<property name="repository" ref="jpaDao"/>
</bean>
<bean class="com.spring.repository".JpaDao"/>
1. The first declared bean MyServiceImpl is missing an id must be named
myService
2. The Second declared bean JpaDao is missing an id must be named
jpaDao
3. Answer 1 and 2 are both rights
4. Answer 1 and 2 are both Wrongs

ANS:2
6.File Entries Imagines that you have a customer files and that you wish to count
the total number of records.Which of the Following JSP structures do you think
would be appropriate to use

1. Sequence
2. Iteration
3. Decision
ANS:2

7.SessionFactory represens which level of catch


1. 2nd
2. 1st
3. 3rd
4. 4th
Ans:1

8.Does hibernate requires persistent classes to implement serializable


1. Required
2. Not Required
3. None

Ans:2

9.How to get Connection object from Session


1. session.getConnection();
2. session.connection();
3. session.createConnection();
4. None
Ans:2

10.How can you make a property be read from the database but not modified in
any way
1. By using the insert=”false” and update=”false” attributes
2. By using the isinsert=”false” and isupdate=”false” attributes
3. By using the isinsert=”no” and isupdate=”no” attributes
4. NONE
Ans:1
11. What will be the output of the program?

class PassS
{
public static void main(String [] args)
{
PassS p = new PassS();
p.start();
}

void start()
{
String s1 = "slip";
String s2 = fix(s1);
System.out.println(s1 + " " + s2);
}

String fix(String s1)


{
s1 = s1 + "stream";
System.out.print(s1 + " ");
return "stream";
}
}

A. slip stream

B. slipstream stream

C. stream slip stream

D. slipstream slip stream

Ans:D

12.Which implicit object is used in a JSP page to retrieve values associated with
<context-param> entries in the deployment descriptor
1. config
2. request
3. session
4. application
Ans:4

13. A developer wants to make a name attribute available to all servlets


associated with a particular user,across multiple requests from that user,from
the same browser instance. which two provide this capability from within a tag
handler
1. pageContext.setAttribute(“name”,theValue);
2. pageContext.setAttribute(“name”,getSession());
3. pageContext.getRequest.setAttribute(“name”,theValue);
4. pageContext.getSession().setAttribute(“name”,theValue);
Ans:4

14.Which method shows the client what server is receiving


1. goGet
2. doOption
3. doTraceC
4. doPost
Ans:3

15.Which listerner should useto find context has been created or destroyed?
1. ServletContextListener
2. ServletContextAttributeListener
3. HttpContextListener
4. Allthe Above
ANS:1

16.If you want to track active session or how many users are there?so which
listener you should use
1. ServletRequesListener
2. ServeletContextListener
3. HttpSessionListener
4. HttpSessionBindingListener
Ans:3

17.Which of these are common mechanisms used for session tracking?


1. URL-rewriting
2. Cookies
3. RequestDispatcher
Ans:2

18.In which of the following type of ResultSet, the cursor can scroll forwards and
backwards, and the result set is sensitive to changes made by others to the
database that occur after the result set was created?
A - ResultSet.TYPE_FORWARD_ONLY

B - ResultSet.TYPE_SCROLL_INSENSITIVE

C - ResultSet.TYPE_SCROLL_SENSITIVE

D - None of the above.

Ans:C

19.Which of the following is used generally used for altering the databases?

A - boolean execute()

B - ResultSet executeQuery()

C - int executeUpdate()

D - None of the above.

Ans:c

20.Which of the following method can be used to create a connection object?

A - getConnection(String url, String user, String password)

B - getConnection(String url)

C - getConnection(String url, Properties prop)

D - All of the above.

Ans:D 

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy