You are on page 1of 24

https://www.sanfoundry.

com/java-questions-answers-freshers-
experienced/

1.Spring is a

A-Framework

B-an open source framework

C-a licensed framework

D-a proprietary framework

2.
Which are the modules of Web layer?
A - WebSocket, Servlet, Web, Portlet
 
B - WebSocket, Servlet, Web-MVC, Web

 
C - HTML, JSP, WEB, Portlet

 
D - HTML, Servlet, WEB, Portlet

3. Which are the correct implementation classes of


ApplicationContext?
A - FileSystemXmlApplicationContext,
ClassPathXmlApplicationContext,
WebXmlApplicationContext
 
B - FileSystemApplicationContext, ClassPathApplicationContext, WebApplicationContext

 
C - AdvancedApplicationContext, FileApplicationContext

 
D - FileSystemApplicationContext, ClassPathApplicationContext

4. What is bean autowiring?


A - Autowiring lets Spring resolve collaborators (other
beans) for your bean by inspecting the contents of the
BeanFactory without using <constructor-arg> and
<property> elements.
 
B - Autowiring injects values in spring beans.

 
C - Autowiring injects one bean into another.

 
D - Autowiring helps in wiring a list of values, allowing duplicates.

5. If a bean is scoped to HTTP request, scope is


 
A - session

 
B - global-session

 
C - prototype

D - request
6. Which of the following class can be used to execute Sql
queries in spring?
 
B - JDBCHelper

A - JdbcTemplate
 
C - DBHelper
 
D - DBTemplate

7. What is Dependency Injection?


A - It is a design pattern which implements Inversion of
Control for software applications.
 
B - It is one of the spring module.

 
C - It is a technique to get dependencies of any project.

 
D - It is used to promote tight coupling in code.

8. Which are the modules of core container?


 
A - Beans, Core, Context, SpEL

 
B - Core, Context, ORM, Web

 
C - Core, Context, Aspects, Test

 
D - Bean, Core, Context, Test

9. What types of Dependency injection does spring supports?


 
A - Constructor based, Setter based

 
B - Constructor based, Setter based, Getter Based

 
C - Setter based, Getter based, Properties based

 
D - Constructor based, Setter based, Properties based

10. Which are the IoC containers in Spring?


A - BeanFactory, ApplicationContext
 
B - BeanFactory, ApplicationContext, IocContextFactory
 
C - BeanFactory, BeanContext, IocContextFactory

 
D - BeanFactory, ApplicationContext, BeanContext

11.  What is spring?


A - Spring is an open source development framework for
enterprise Java.
B - Spring is a proprietary framework.
C - Spring is a development framework for .Net applications.
D - Spring is a development framework for PHP based
applications.
12.Which of the following class can be used to call Stored
Procedures in spring?
 
A - SPHelper

 
B - JdbcTemplateCall

 
C - JdbcTemplate

D - SimpleJdbcCall
13. Which class acts as IoC Container?
 
A - ServletContext

 
B - DispatcherServlet

C - ApplicationContext
 
D - None of the above
14. Which of the following is correct about dependency
injection?
A - It helps in decoupling application objects from each
other.
 
B - It helps in deciding the dependencies of objects.

 
C - It stores objects states in database.

 
D - It stores object states in file system.

15. What is default scope of bean in Spring framework?


A - singleton
 
B - prototype

 
C - request

 
D - session

16. Which of the following is true about SessionFactory object


in hibernate?
 
A - SessionFactory object configures Hibernate for the application using the supplied configuration file.

 
B - SessionFactory object allows for a Session object to be instantiated.

 
C - The SessionFactory is a thread safe object.

D - All of the above.


17. Which of the following element maps java.util.SortedMap
property in hibernate?
 
A - <set>

 
B - <list>

 
C - <bag>

D - <map>
18. Which of the following is a core component of Hibernate?
 
A - Transaction

 
B - SessionFactory

 
C - Session

D - All of the above


19. What ORM stands for?
A - Object Relation Map
B - Object Relational Mapping
C - Object Record Mapping
D - None of the above.
20. Which of the following is true about <class> element?
 
A - The <class> elements are used to define specific mappings from a Java classes to the database tables.

 
B - The Java class name is specified using the name attribute of the class element.

 
C - The database table name is specified using the table attribute of the class element.

D - All of the above.


21. Which of the following element is used to represent many-
to-one relationship in hibernate?
A - <many-to-one>
 
B - <many-one>

 
C - <ManyToOne>

 
D - None of the above

22. Is second level caching mandatory in hibernate?


 
A - true

B - false
23. Which of the following database is supported by Hibernate?
 
A - DB2/NT

 
B - PostgreSQL

 
C - Sybase SQL Server

D - All of the above


24.Which of the following is true about hibernate annotations?
A - Hibernate Annota2tions is the powerful way to provide
the metadata for the Object and Relational Table mapping.
 
B - All the metadata is clubbed into the POJO java file along with the code this helps the user to understand
the table structure and POJO simultaneously during the development.

 
C - Both of the above.

 
D - None of the above.
25. Which of the following is true about ORM?
 
A - ORM stands for Object-Relational Mapping.

 
B - ORM is a programming technique for converting data between relational databases.

C - Both of the above.


 
D - None of the above.

26. Which of the following elements is used to define specific


mappings from a Java classes to the database tables?
 
A - property

 
B - hibernate-config

C - class
 
D - class-config

27. Which of the following element maps java.util.List property


in hibernate?
 
A - <set>

B - <list>
 
C - <bag>

 
D - <map>

28. Which of the following element is used to represent one-to-


many relationship in hibernate?
A - <one-to-many>
B - <one-many>
C - <OneToMany>
D - None of the above.
29.Which of the following is true about hibernate.dialect
property in hibernate configuration?
A - This property makes Hibernate generate the
appropriate SQL for the chosen database.
 
B - This property makes Hibernate generate the appropriate java code for the chosen database.

 
C - Both of the above.

 
D - None of the above.

30. Which method is used to save or update the state of the


given instance from the underlying database?
A - Session.saveOrUpdate()
 
B - Session.keep()

 
C - Session.update()

 
D - Session.load()

31. What is the difference between save() and persist() methods


of session object?
 
A - There is no difference.

 
B - save saves the object and returns status whereas persist stores status in different variable.

C - save saves the object and returns the id of the instance
whereas persist do not return anything after saving the
instance.
 
D - None of the above.

32. What HQL stands for?


A - Hibernate Query Language
 
B - High Query Language

 
C - Hybrid Query Language

 
D - None of the above.

33. The SessionFactory is heavyweight object.


 
A - false

B - true
34. name attribute of @Column annotation permits the name of
the column to be explicitly specified.
A - true
 
B - false

35. Which of the following is true about <property> element?


 
A - The <property> element is used to map a Java class property to a column in the database table.

 
B - The name attribute of the element refers to the property in the class.

 
C - The column attribute of the element refers to the column in the database table.

D - All of the above.


36. Which of the following is not a core component of
Hibernate?
 
A - Transaction

 
B - Provider

 
C - Criteria

 
D - Query

37. Which method is used to save the state of the given instance
from the underlying database?
 
A - Session.store()

 
B - Session.keep()

C - Session.save()
 
D - Session.load()

38. Which of the following is true about hibernate?


 
A - Hibernate does not require an application server to operate.

 
B - Hibernate manipulates Complex associations of objects of your database.

 
C - Hibernate minimize database access with smart fetching strategies.

D - All of the above.


39. Which of the following is true about @Entity annotation?
 
A - @Entity annotation marks a class as an entity bean.

 
B - Class marked with @Entity annotation must have a no-argument constructor that is visible with at least
protected scope.

C - Both of the above.


 
D - None of the above

40.  Which element of hbm.xml defines maps the unique ID


attribute in class to the primary key of the database table?
A - id
 
B - generator

 
C - primaryKey

 
D - None of the above.

41. Which of the following element maps java.util.Set property


in hibernate?
 
A - <set>

 
B - <list>

 
C - <bag>

 
D - <map>

42. Which of the following is true with respect to ORM vs


JDBC?
 
A - ORM system lets business code access objects rather than DB tables.

 
B - ORM system hides details of SQL queries from OO logic.

 
C - ORM system helps in Transaction management and automatic key generation.

D - All of the above.


43. This object can be used to access other implicit objects in JSP.
A - request
B - page

C - context

D - pageContext

44. Which of the following attributes are mandatory in <jsp:getProperty /> tag?
A - name, property

B - type, id

C - name, type

D - id, property

45. Which of the following method can be used to read a form parameter in JSP?

A - request.getParameter()

B - response.getParameter()

C - request.getValue()

D - response.getValue()

46. Which of the following is true about <c:choose> tag?

A - The <c:choose> works like a Java switch statement in that it lets you choose between a number of
alternatives.

B - The <c:choose> tag has <c:when> tags.

C - The <c:choose> tag has <otherwise> as default clause.

D - All of the above.

47.  request is instance of which class?


A - Request

B - HttpRequest

C - HttpServletRequest

D - ServletRequest

48. Which of the following is not a valid attribute of a page directives?

A - language

B - extend

C - export

D - import

49. Which of the following attribute is used to mark a page as error processing page?

A - isErrorPage

B - errorPage

C - exception

D - exceptionPage

50. What is the use of <c:if> tag?


A - It is used to check if jsp tag library is enabled or not.

B - It evaluates an expression and displays its body content only if the expression evaluates to true.

C - Both of the above.

D - None of the above.


51. Which of the following attributes are mandatory in <jsp:useBean /> tag?

A - id, type

B - id, class

C - type, class

D - type,property

52. Which of the following attribute is used to have uncaught run-time exceptions automatically forwarded to
an error processing page?

A - error

B - errorPage

C - exception

D - exceptionPage

53. Which of the following is true about autoFlush Attribute?

A - The autoFlush attribute can specify that buffered output should be flushed automatically when the buffer is
filled.

B - The autoFlush attribute can specify that an exception should be raised to indicate buffer overflow.

C - Both of the above.

D - None of the above.

54. Is it possible to include files using absolute path in a JSP page using include directive?
A - true
B - false

55. What is Internationalization?


A - Internationalization means creating international content on a website.

B - Internationalization means enabling a web site to provide different versions of content translated
into the visitor's language or nationality.

C - Internationalization refers to creating local content on a website.

D - None of the above.

56. Which of the following is true about <c:redirect> tag?


A - The <c:redirect > tag redirects the browser to an alternate URL by providing automatically URL rewriting.

B - The <c:redirect > tag supports context-relative URLs.

C - The <c:redirect > tag supports <c:param> tag.

D - All of the above.

57. Which of the following is not a implicit object?


A - request

B - response

C - cookie

D - session

58. What JSP stands for?


A - Java Service Programming

B - Java Server Programming


C - Java Service Pages

D - Java Server Pages

59. config is instance of which class?


A - javax.servlet.ServletContext

B - javax.servlet.ServletConfig

C - javax.servlet.Context

D - javax.servlet.Application

60. Which of the following is true about include directive?


A - The include directive is used to include a file during the translation phase.

B - include directive tells the container to merge the content of other external files with the current JSP during
the translation phase.

C - Both of the above.

D - None of the above.

61. Which of the following depicts correct order of phases in JSP life cycle?
A - Compilation, Initialization, Execution, Cleanup

B - Initialization, Compilation, Cleanup, Execution

C - Initialization, Cleanup, Compilation, Execution

D - Cleanup, Compilation, Initialization, Execution

62. Which of the following attributes are used in <jsp:include /> tag?
A - id, type
B - page, flush

C - type, class

D - type,page

63. What is difference between <%-- comment --%> and <!-- comment -->?
A - <%-- comment --%> is JSP comment. <!-- comment --> is an HTML comment.

B - <%-- comment --%> is ignored by JSP container.

C - <!-- comment --> is ignored by browser.

D - All of the above.

64. Which of the following is true about <c:forEach > tag?


A - The <c:forEach > exists as a good alternative to embedding a Java for, while, or do-while loop via a
scriptlet.

B - The <c:forEach > is used to iterate over a list of items in jsp.

C - Both of the above.

D - None of the above.

65. If a jsp is to generate a pdf page, what attribute of page directive it should use?
A - contentType

B - generatePdf

C - typePDF

B - contentPDF

66. Which of the following are the valid scopes in JSP?


A - request, page, session, application

B - request, page, session, global

C - response, page, session, application

D - request, page, context, application

67. What are cookies?


A - Cookies are text files stored on the client computer and they are kept for various information
tracking purpose.

B - Cookies are binary files stored on the server computer and they are kept for various information tracking
purpose.

C - Cookies are binary files stored on the client computer and they are kept for data storage purpose.

D - None of the above.

68. What is Localization?


A - Localization refers to creating local content on a website.

B - Localization refers to adding locale related information to a website.

C - Localization means adding resources to a web site to adapt it to a particular geographical or cultural
region for example Hindi translation to a web site.

D - None of the above

69. What's the difference between JavaBeans and taglib directives?


A - Taglibs are for generating presentation elements while JavaBeans are good for storing information
and state.

B - Custom tags are used to implement actions and JavaBeans are used to present information.
C - Both of the above.

D - None of the above.

70.  isErrorPage is by default true.


A - True

B - False

71. What type of servlets use these methods doGet(), doPost(),doHead,


doDelete(), doTrace()?

a. Generic Servlets
b. HttpServlets
c. All of the above
d. None of the above
72. Which cookie it is valid for single session only and it is removed each time
when the user closes the browser?

a. Persistent cookie
b. Non-persistent cookie
c. All the above
d. None of the above
73.   Which method is used to send the same request and response objects to
another servlet in RequestDispacher ?

a. forward()
b. sendRedirect()
c. Both A & B
d. None of the above
74. Which packages represent interfaces and classes for servlet API?

a. javax.servlet
b. javax.servlet.http
c. Both A & B
d. None of the above
75. Which class can handle any type of request so that it is protocol-
independent?
a.GenericServlet
b. HttpServlet
c. Both A & B
d. None of the above
76. Which HTTP Request method is non-idempotent?

a.GET
b. POST
c. BOTH A & B
d. None of the above
77. Which object is created by the web container at time of deploying the
project?

a.ServletConfig
b. ServletContext
c. Both A & B
d. None of the above

78. What is the lifecycle of a servlet?

a. Servlet class is loaded


b. Servlet instance is created
c. init,Service,destroy method is invoked
d. All mentioned above

79. Which method in session tracking is used in a bit of information that is


sent by a web server to a browser and which can later be read back from that
browser?
a.HttpSession
b. URL rewriting
c. Cookies
d. Hidden form fields

80. Which one of the following scopes does the attribute in servlet is an object
that can be set, get or removed?

a.session scope
b. request scope
c. application scope
d. All mentioned above
81. Which are the examples of Application Server?

a.Apache
b. Tomcat
c. JBoss
d. Weblogic
e. Both C & D

82. In the following statements identify the disadvantages of CGI?

a.If number of clients increases, it takes more time for sending response
b. For each request, it starts a process and Web server is limited to start processes
c. It uses platform dependent language e.g. C, C++, perl
d. All mentioned above

83. When we are sending data in URL in get method, how to separate separate
path and parameter?

a.comma

b.?

c.&

d.None of these

84.CGI stands for ?

a.Common Gateway Interface

b.Common Gateway Internet

c.Commonality Gateway Inline

d.Common Gateway Inline

85.Servlet is _______side programming language.

a.Server
b.Client

c.Both A and B

d.None of these

86.PrintWriter is in _______package.

a.io

b.util

c.servlet

d.None of these

87.HttpServlet is present in _________package

a.javax.servlet

b.javax.servlet.http

c.java.servlet.http

d.None of these

88.GenericServlet is present in _________package

a.javax.servlet

b.javax.servlet.http

c.java.servlet.http

d.None of these

89.RequestDispatcher is present in _______package.

a.javax.servlet

b.javax.servlet.http

c.java.servlet.http

d.None of these
90.URL rewriting uses ________html element to send data.

a. <a>
b. <li>
c. <ul>
d. None of these

91._______among the following is used to send data and requires extra page
submission.

a.Hidden form field

b.Session

c.SessionFactory

d.None of these

You might also like