Don't let the Lockdown slow you Down - Enroll Now and Get 3 Course at 24,999/- Only. Explore Now!

Interview Questions

J2EE Interview Questions and Answer

Top J2EE Interview Questions and Answers

J2EE Interview Questions and answers

J2EE Interview Questions and answers for beginners and experts. List of frequently asked J2EE Interview Questions with answers by Besant Technologies. We hope these J2EE Interview Questions and answers are useful and will help you to get the best job in the networking industry. This J2EE Interview Questions and answers are prepared by J2EE Professionals based on MNC Companies expectation. Stay tuned we will update New J2EE Interview questions with Answers Frequently. If you want to learn Practical J2EE Training then please go through this J2EETraining in Chennai .

Best J2EE Interview Questions and answers

Besant Technologies supports the students by providing J2EE Interview Questions and answers for the job placements and job purposes. J2EE is the leading important course in the present situation because more job openings and the high salary pay for this J2EE and more related jobs. We provide the J2EEonline training also for all students around the world through the Gangboard medium. These are top J2EE Interview Questions and answers, prepared by our institute experienced trainers.

J2EE Interview Questions and answers for the job placements

Here is the list of most frequently asked J2EE Interview Questions and answers in technical interviews. These questions and answers are suitable for both freshers and experienced professionals at any level. The questions are for intermediate to somewhat advanced J2EE professionals, but even if you are just a beginner or fresher you should be able to understand the answers and explanations here we give.

Q1) Autocloseable was introduced in ?

a) java SE 7
b) java SE 8
c) java SE 6
d) java SE 4

Answer: a) java SE 7

Q2) An alternative way of using finally to close resource is by

a) catch block
b) autocloseable interface to be implemented
c) try block
d) throw Exception

Answer: b) autocloseable interface to be implemented

Q3) Flushable interface was introduced in ?

a) java SE 7
b) java SE 8
c) java SE 6
d) java SE 5

Answer: d) java SE 5

Q4) ________ is not a maven goal.

a) clean
b) package
c) install
d) debug

Answer: d) debug

Q5) _________ is used to specify the packaging cycle.

a) build.x
b) pom.xml
c) dependency.xml
d) version.xml

Answer: a) build.xml

Q6) __________ is used to specify the path to maven.

a) JAVA_HOME
b) PATH
c) MAVEN_HOME
d) CLASSPATH

Answer: c) MAVEN_HOME

Q7) Which one of the following annotations is not used in Hibernate?

a) @Entity
b) @Column
c) @Basic
d) @Query

Answer: d) @Query

Q8) Java introduced annotation in ?

a) Java 5
b) Java 6
c) Java 7
d) Java 8

Answer: a) Java 5

Q9) Which one of the following is not an annotation used by Junit with Junit4?

a) @Test
b) @BeforeClass
c) @AfterClass
d) @Ignored

Answer: d) @Ignored

Q10) _________ is the Parent class of annotation class?

a) Class
b) Object
c) Main
d) Super

Answer: b) Object

Q11) The remaining capacity of BlockingQueue whose intrinsic capacity is not defined is _________

a) Integer.MAX_VALUE
b) BigDecimal.MAX_VALUE
c) 99999999
d) Integer.INFINITY

Answer: a) Integer.MAX_VALUE

Q12) What is the difference between Queue and Stack?

a) Queue is FIFO; Stack is LIFO;
b); Stack is FIFO; Queue is LIFO
c) Stack and Queue is FIFO
d) Queue and Stack is LIFO

Answer: a) Queue is FIFO; Stack is LIFO;

Q13) To simulate if then behavior in Junits we use.......?

a) if[..] else[..]
b) if(..)[..] else[..]
c) Mockito.when(…).thenReturn(…);
d) Mockito.if(..).then(..);

Answer: c) Mockito.when(…).thenReturn(…);

Q14) What is used to inject mock fields into the tested object automatically?

a) @InjectMocks
b) @Inject
c) @InjectMockObject
d) @Mock

Answer: a) @InjectMocks

Q15) Which object stores references to the request and response objects?

a) sessionContext
b) pageContext
c) HttpSession
d) sessionAttribute

Answer: b) pageContext

Q16) Which tag is used to set a value of a JavaBean?

a) <c:set>
b) <c:param>
c) <c:choose>
d) <c:forward>

Answer: a) <c:set>

Q17) Which of the following is not a directive in JSP?

a) page directive
b) include directive
c) taglib directive
d) command directive

Answer: d) command directive

Q18) Which of the following is not an inheritance mapping strategies?

a) Table per hierarchy
b) Table per concrete class
c) Table per subclass
d) Table per class

Answer: d) Table per class

Q19) n which file database table configuration is stored?

a) .dbm
b) .hbm
c) .ora
d) .sql

Answer: b) .hbm

Q20) Which of the following method is used inside session only?

a) merge()
b) update()
c) end()
d) kill()

Answer: b) update()

Q21) Which of the following code is used to get an attribute in a HTTP Session object in servlets?

a) session.getAttribute(String name)
b) session.alterAttribute(String name)
c) session.updateAttribute(String name)
d) session.setAttribute(String name)

Answer: a) session.getAttribute(String name)

Q22) Which of the following is true about servlets?

a) Servlets execute within the address space of web server
b) Servlets are X-platform because they are written in java
c) Servlets can utilize full functionality of the Java class libraries
d) Servlets execute within the address space of web server, It is cross-platform and utilize all functionality of java class libraries

Answer: d) Servlets execute within the address space of web server, It is cross-platform and utilize all functionality of java class libraries

Q23) How constructor can be used for a servlet?

a) Initialization
b) Constructor function
c) Initialization and Constructor function
d) Setup() method

Answer: c) Initialization and Constructor function

Q24) Which design pattern ensures that only one object of particular class gets created?

a) Singleton pattern
b) Filter pattern
c) State pattern
d) Bridge pattern

Answer: a) Singleton pattern

Q25) What does MVC pattern stands for?

a) Mock View Control
b) Model view Controller
c) Mock View Class
d) Model View Class

Answer: b) Model view Controller

Q26) Which design pattern represents a way to access all the objects in a collection?

a) Iterator pattern
b) Facade pattern
c) Builder pattern
d) Bridge pattern

Answer: a) Iterator pattern

Q27) Which of the following is not a feature of Beans?

a) Introspection
b) Events
c) Persistence
d) Serialization

Answer: d) Serialization

Q28) How to specify autowiring by name?

a) @Qualifier
b) @Type
c) @Constructor
d) @Name

Answer: a) @Qualifier

Q29) Which of the following is correct error when loading JAR file with duplicate name?

a) java.io.NullPointerException
b) java.lang.ClassNotFound
c) java.lang.ClassFormatError
d) java.lang.DuplicateClassError

Answer: c) java.lang.ClassFormatError

Q30) Which of these is an correct way making a list that is upper bounded by class Number?

a) List<? extends Number>
b) List<extends ? Number>
c) List(? extends Number)
d) List(? UpperBounds Number)

a) List<? extends Number>

Q31) Which of these is wildcard symbol?

a) ?
b) !
c) %
d) &

Answer: a) ?

Q32) What are the two types of Streams offered by java 8?

a) sequential and parallel
b) sequential and random
c) parallel and random
d) random and synchronized

Answer: a) sequential and parallel

33) What is Optional object used ?

a) for optional runtime argument
b) for optional spring profile
c) to represent null with absent value
d) it’s not mandatory for method to return object

Answer: c) to represent null with absent value

Q34) What is the substitute of Rhino javascript engine in Java 8?

a) Nashorn
b) V8
c) Inscript
d) Narcissus

Answer: a) Nashorn

Q35) Which feature of java 8 enables us to create a work stealing thread pool using all available processors
at its target?

a) workPool
b) newWorkStealingPool
c) threadPool
d) workThreadPool

Answer: b) newWorkStealingPool

Q36) Which of these class allows us to define our own formatting pattern for dates and time?

a) DefinedDateFormat
b) SimpleDateFormat
c) ComplexDateFormat
d) UsersDateFormat

Answer: b) SimpleDateFormat

Q37) Which of these data type cannot be type parameterized?

a) Array
b) List
c) Map
d) Set

Answer: a) Array

Q38) What is synchronization in reference to a thread?

a) the process of handling shared resource between two or more threads.
b) It’s a process by which many thread are able to provide simultaneous access same shared resource
c) It’s a process by which a method is able to provide simultaneous access many different threads
d) It’s a method that allow too many threads to access any kind of information it needs.

Answer: a) the process of handling shared resource between two or more threads.

Q39) Which component is responsible to optimize bytecode to machine code?

a) JVM
b) JDK
c) JIT
d) JRE

Answer: c) JIT

Q40) What is use of interpreter?

a) They convert bytecode to machine language code
b) They read high level code line by line and execute them simultaniously
c) They are intermediated between JIT and JVM
d) It is a synonym for JIT

Answer: b) They read high level code line by line and execute them simultaniously

Q41) Which of these is a method of class Date which is used to search whether object contains a date before the specified date?

a) after()
b) contains()
c) before()
d) compareTo()

Answer: c) before()

Q42) Which of these methods calls update() method?

a) notify()
b) observeObject()
c) updateObserver()
d) notifyObserver()

Answer: d) notifyObserver()

Q43) Which of these package provides the ability to read and write in Zip format?

a) java.lang
b) java.io
c) java.util.zip
d) java.util.zar

Answer: c) java.util.zip

Q44) Observable class is used _______?

a) to create global subclasses
b) to create classes that other part of the program can observe
c) to create classes that can be accessed by other parts of program
d) to create methods that can be accessed by other parts of program

Answer: b) to create classes that other part of the program can observe

Q45) What is the name of a data member of class Vector which is used to store a number of elements in the vector?
a) length

b) elements
c) elementCount
d) capacity

Answer: c) elementCount

Q46) Which of these are integer constants of TextEvent class?

a) TEXT_CHANGED
b) TEXT_FORMAT_CHANGED
c) TEXT_VALUE_CHANGED
d) TEXT_sIZE_CHANGED

Answer: c) TEXT_VALUE_CHANGED

Q47) Which of these is superclass of WindowEvent class?a) WindowEvent

b) ComponentEvent
c) ItemEvent
d) InputEvent

Answer: b) ComponentEvent

Q48) Which of these events is generated by scroll bar?

a) ActionEvent
b) KeyEvent
c) WindowEvent
d) AdjustmentEvent

Answer: d) AdjustmentEvent

Q49) Which of these Exceptions is thrown by loadClass() method of ClassLoader class?

a) IOException
b) SystemException
c) ClassFormatError
d) ClassNotFoundException

Answer: d) ClassNotFoundException

Q50) Which of these methods can be used to determine the type of event?

a) getID()
b) getSource()
c) getEvent()
d) getEventObject()

Answer: a) getID()

Q51)What is a JDBC Driver? Do you know JDBC drivers?

JDBC driver is software that is used to connect applications using the database.

We have four JDBC drivers

  • Jdbc-odbc bridge driver 2.network protocol driver 3. Native api driver .4 thin driver.

Q52)Do you know the JDBC API?

Yes, I know. we have connection, statement, prepared statement, resultset, callable statement..etc JDBC APIs are there.

Q53)What is the difference between executing and executeQuery methods?

By using the execute method we can execute update and selection SQL operations and this returns Boolean

By using the executeQuery method we can execute the select SQL operation only and it returns the result set object.

Q54)How to execute stored procedures in JDBC?

Using the callable statement of prepare all method we can execute stored procedures in JDBC.

Q55)How to store binary data using JDBC?

Using blob and clob data types we can store binary data and character data in the database using JDBC.

Q56)Do you know the steps to connect relational databases?

Yes, I know how to connect the database using JDBC. The following are the steps to connect the database using JDBC,

  • First, we need to load the driver class based on the database you want to use.
  • Create the connection using the connection interface
  • Create the statement using the statement interface
  • Execute the queries whichever you want like select, update, create..etc
  • Finally, close the connection

Q57)What are the resultset types?

We have three result set types, 1. ResultSet.type_forward_only 2. ResultSet.type_scroll_incensitive 3. ResultSet.type_scroll_sensitive

Q58)What is Deployment Descriptor in Servlets?

Web.xml is called a deployment descriptor in servlets. Every deployment descriptor has a servlet configured with URL pattern for any request processing.

Q59)List out annotations used in Servlet 3? Explain

We have mainly 3 annotations in servlet.

  • @WebServlet: Used for servlet class.
  • @WebListener: Used for listener class.
  • @WebFilter:  Used for filter class.

Q60)What is forward() method and sendRedirect() methods in Servlet?

1. Forward is used to sending the same request and sendRedirect sends a new request.

2. Forward request works for client-side and sendRedirect works for server-side.

Q61)What is the purpose of RequestDispatcher in Servlets?

RequestDispacher is an interface it is used to dispatch the requested resource like JSP, HTML, servlet.

Q62)Difference between ServletContext and ServletConfig?

The Servlet container creates  ServletConfig for each servlet and the ServletContext object is created for each web application.

Q63)What are session tracking techniques in servlets?

We have four session tracking techniques in servlets,

  • By using cookies
  • By using URL rewriting using HTTP session
  • BY using hidden fields

Q64)Do you know how to implement servlets?

Yes I know how implement servlets using http servlet and generic servlets.

Q65)Servlets are synchronized or not?

No servlets are not synchronized. Tf you want to make synchronized we need to implement single thread interface in your class.

Q66)What are the HTTP methods?

Mainly used HTTP methods are, Get, Post, Put, Delete.

Q67)What is the difference between war and ear files?

War files indicate the web applications whereas ear files are enterprise applications. War files run web server application server and ear runs only enterprise server.

Q68)How many types of objects are there in JSP program?

  • We have two object  types in JSP,
  • Implicit objects (automatically created in JSP equivalent servlet program)
  • Explicit objects (created by programmer manually)

Q69)What are the JSP life cycle methods?

There are three life cycles methods in jsp,

  • JspInit()
  • _jspService()
  • jspDestroy()

Q70)How to handle errors in jsp?

Two ways we can handle errors/exceptions in JSP,

  • By using errorPage and isErrorPage attributes of Page Directive
  • By using <error-page> xml tag ini web.xml

Q71)What are the implicit objects in jsp?

In Jsp we have 9 implicit objects

  1. Request
  2. Page,
  3. The session
  4. Application,
  5. Out,
  6. Config
  7. Exception
  8. PageContext
  9. Response

Q72)What are the standard elements of JSP? Explain.

  • Scriptlet(<%——-%>)
  • Expression(<%=——-%>)
  • Declaration(<%!———%>

Q73)List some jsp action tags?

Some of the jsp action tags are,

  1. <Jsp:forward>
  2. <Jsp:include>
  3. <Jsp:useBean>
  4. <Jsp:setProperty>
  5. <Jsp:getProperty>

Q74)How many to import the package in the JSP program?

Two ways we can import the packages in JSP

  • Using JSP directive tags 2. Using the Import statement

Q75)Do you know the scopes in JSP?

  1. We have four scopes in JSP, 1. Page,2. Request. 3. Session 4. Application.

Q76)How many tags are provided in JSTL?

  1. We have five JSTL tags 1. Core tags 2 SQL tags 3. XML tags 4. Functional tags 5.internalzation tags

Q77)Do know how to disable the session in JSP?

  1. Using the page session attribute we can disable the session in jsp page.
  2. <%@ page session=”false” %>

Q78)What are the Literals used in JSP?

  1. We have the following literals in JSP,
  2. Null, Boolean, String, Float, and integer

Q79)Tell me uses of JSP over Servlets?

  1. Some of the Major Advantages of JSP over Pure Servlets
  2. It is easy convenient to write and modify HTML
  3. printin statements that generate the HTML.
  4. Writing Java code in HTML pages.
  5. Platform independence.
  6. Server-side programming.
Scroll Up
Besant Technologies WhatsApp