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.
Answer: d) debug
Q5) _________ is used to specify the packaging cycle.
Answer: a) build.xml
Q6) __________ is used to specify the path to maven.
Answer: c) MAVEN_HOME
Q7) Which one of the following annotations is not used in Hibernate?
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?
Answer: d) @Ignored
Q10) _________ is the Parent class of annotation class?
Answer: b) Object
Q11) The remaining capacity of BlockingQueue whose intrinsic capacity is not defined is _________
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[..]
Answer: c) Mockito.when(…).thenReturn(…);
Q14) What is used to inject mock fields into the tested object automatically?
Answer: a) @InjectMocks
Q15) Which object stores references to the request and response objects?
Answer: b) pageContext
Q16) Which tag is used to set a value of a JavaBean?
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?
Answer: b) .hbm
Q20) Which of the following method is used inside session only?
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?
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?
Answer: d) Serialization
Q28) How to specify autowiring by name?
Answer: a) @Qualifier
Q29) Which of the following is correct error when loading JAR file with duplicate name?
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?
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
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?
Answer: b) newWorkStealingPool
Q36) Which of these class allows us to define our own formatting pattern for dates and time?
Answer: b) SimpleDateFormat
Q37) Which of these data type cannot be type parameterized?
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?
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?
Answer: c) before()
Q42) Which of these methods calls update() method?
Answer: d) notifyObserver()
Q43) Which of these package provides the ability to read and write in Zip format?
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?
Answer: c) elementCount
Q46) Which of these are integer constants of TextEvent class?
Answer: c) TEXT_VALUE_CHANGED
Q47) Which of these is superclass of WindowEvent class?a) WindowEvent
Answer: b) ComponentEvent
Q48) Which of these events is generated by scroll bar?
Answer: d) AdjustmentEvent
Q49) Which of these Exceptions is thrown by loadClass() method of ClassLoader class?
Answer: d) ClassNotFoundException
Q50) Which of these methods can be used to determine the type of event?
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,
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
- The session
Q72)What are the standard elements of JSP? Explain.
Q73)List some jsp action tags?
Some of the jsp action tags are,
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?
- We have four scopes in JSP, 1. Page,2. Request. 3. Session 4. Application.
Q76)How many tags are provided in JSTL?
- 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?
- Using the page session attribute we can disable the session in jsp page.
- <%@ page session=”false” %>
Q78)What are the Literals used in JSP?
- We have the following literals in JSP,
- Null, Boolean, String, Float, and integer
Q79)Tell me uses of JSP over Servlets?
- Some of the Major Advantages of JSP over Pure Servlets
- It is easy convenient to write and modify HTML
- printin statements that generate the HTML.
- Writing Java code in HTML pages.
- Platform independence.
- Server-side programming.