|
|
JAVA/J2EE INTERVIEW QUESTIONs:- Explain many types of design pattern?
Factory design pattern:- Defines an interface for creating an object , but lets the sub class de
|
Java Training: - Show Bootstrap, Extension and System Class loader?
There three types of class loaders:-
Bootstrap Class loader also called as primordial class loader.
Extension Class loader.
System Class loader.
Let’s now try to get the fundamentals of these class loaders.
Bootstrap Class loader
Bootstrap class loader loads those classes those which are essential for JVM to function properly. Bootstrap class loader is responsible for loading all core java classes for instance java.lang.*, java.io.* etc. Bootstrap class loader finds
|
Java Training: - What is the concept of local interfaces?
One of the biggest issues of creating objects using home interface is performance. Below are the steps which follow when you call the EJB object:-
JAVA client calls the local stub.
Stub marshal the values in to some other form which the network understands and sends it to the skeleton.
Skeleton then de-marshals it back to a form which is suitable for JAVA.
Skeleton then calls the EJB object and methods.
EJB object then does object creation, connection pooling, transaction et
|
Java Training: - Different types of resultset?
“ResultSet” is an object that contains the results of SQL query. That means it contains the rows that satisfy the conditions of the query.
There are three basic types of resultsets:-
Forward-only results set
These types of resultset are non-scrollable and moves only forward.
Scroll-insensitive set
Resultset is scrollable so the cursor can move forward, backward, to a particular row etc.
While the resultset is open it does not show any changes done to the underlying databas
|
Java Training: - Elaborate “ResultSet”, “RowSet”, “CachedRowset”, “JdbcRowset” and “WebRowSet” relation ship?
Below are the major points of difference:-
“ResultSet” is a connected architecture while “RowSet” is a disconnected architecture.
As “ResultSet” is a connected architecture we cannot serialize the object while “RowSet” can be serialized.
“RowSet” object is a Java bean while “ResultSet” is not. In the below diagram you can see “RowSet” interface also derives from “BaseRowSet” interface. “BaseRowSet” interface has all the ingredients to make it a Java bean.
Below diagram show
|
Java Training: - What is the difference between JNDI context, Initial context, session context and EJB context?
JNDI context
JNDI Context Provides a mechanism to lookup resources on the network
Initial context
Initial Context constructor provides the initial context.
Session context
Session Context has all the information a session bean would require from the container
Entity Context
Entity Context has all the information that an Entity bean would need from a container
EJB context
EJB Context contains the information that is common to both the session and entity bean
|
What do you mean stateful and stateless session bean?
Stateful Session bean:-
Stateful session bean maintain the state of the conversation between the client and itself
When the client invokes a method on the bean the instance variables of the bean may contain a state but only for the duration of the invocation
implements the javax.ejb.SessionBean interface and is deployed with the declarative attribute "stateful"
Stateless session bean:-
A stateless session bean is an enterprise bean that provides a stateless servi
|
Java Training: - Explain ORM and different levels of ORM quality?
ORM: -
ORM stands for Object/Relational mapping which is mainly used to remove the difference between object oriented and relation model
Different levels of ORM quality: -
Pure relational entire application, including the user interface, is designed around the relational model and SQL-based relational operations
Light object mapping The entities are represented as classes that are mapped manually to the relational tables
Medium object mapping The application is designed
|
Java Training: - Can you explain marshaling and unmarshalling?
Marshaling: -
Marshalling creates an XML document from a content tree.
To marshal a content tree,
Create a JAXBContext object
Create a Marshaller object (Marshaller marshaller = jaxbContext.createMarshaller();)
Set required properties using setProperty method of Marshaller marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, new Boolean(true));
Call the marshal method marshaller.marshal(collection, new FileOutputStream("jaxbOutput.xml"));
Unmarshalling:
|
Java Interview Questions: - Explain navigation rules and how to declare the same?
Navigation rules tells JSF implementation which page to send back to the browser after a form has been submitted
The above configuration says that navigation will happen to page2.jsp if the action eventAction happens inside page1.jsp
See the following video on Getting Started with Servlet in Java: -
Click to get Java Interview Questions
Regards,
Get more Java Interview Questions from author’s blog
|
Java Training: - Can you explain differences between DTDs and Schema?
See the following video on overview on Servlets in Java: -
Click to get Java Training
Regards,
Get more Java Training from author’s blog
|
Java Training: - Can you explain Bean lifecycle in Spring framework?
The spring container finds the beans definition from the XML file and instantiates the bean
Using the dependency injection, spring populates all of the properties as specified in the bean definition
If the bean implements the BeanNameAware interface, the factory calls setBeanName() passing the bean’s ID
If the bean implements the BeanFactoryAware interface, the factory calls setBeanFactory(), passing an instance of itself
If there are any BeanPostProcessors associated with t
|
Java Interview Questions: - Show blocking Queues in Java?
The java.util.concurrent package contains a set of synchronized Queue interfaces and classes. Blocking Queue extends Queue with operations that wait for the queue to become nonempty when retrieving an element and for space to become available in the queue when storing an element. This interface is implemented by the following classes:
LinkedBlockingQueue — an optionally bounded FIFO blocking queue backed by linked nodes
ArrayBlockingQueue — a bounded FIFO blocking queue backed by
|
Java Interview Questions: - What do you mean by Passivation and Activation in EJB?
When we are dealing with stateful session beans we need to store the client conversation of the bean so that it can be available in client’s next request. But when we talk about server it has limited resources. If the conversation of the bean is large then the server can run out of resource. So in order to preserve resources EJB server swaps this conversational data in memory to hard disk thus allowing memory to be reclaimed. This process of saving the memory data to hard disk is called as “Pas
|
Java Training: -What do you mean by JAXR?
JAXR is a standard API used to access XML registries from the JAVA platform. An XML registry is a listing of services available on the Web. JAXR provides APIs for the client applications to query the registries, or publish their own information in them using the registry standards.
It acts as a pluggable layer that allows access to registries implemented on different standards, such as Universal Description Discovery and Integration (UDDI) and Electronic Business using eXtensible Markup Lang
|
Java Training: -What is SOAP?
SOAP is an XML-based protocol that enables software components and applications to communicate with one another. It defines rules to translate application and platform-specific data into the XML format. SOAP allows you to communicate with the Web Service using protocols such as HTTP and Simple Mail Transfer Protocol.
SOAP has three main sections:-
• Envelope: Contains elements such as the header and body of the SOAP messaging structure. It also includes an encodingStyle attribute that s
|
Java Training: - What are the different scopes of an object can have in a JSP page?
There are four scope which an object can have in a JSP page:-
Page Scope
Objects with page scope are accessible only within the page. Data only is valid for the current response. Once the response is sent back to the browser then data is no more valid. Even if request is passed from one page to other the data is lost.
Request Scope
Objects with request scope are accessible from pages processing the same request in which they were created. Once the container has processed the req
|
Java Training: - What is ACID in transaction?
A transaction is proper if it fulfils ACID properties. These four properties are as below:-
Atomicity: - This rule states if one part of the transaction fails then the entire transaction should fail.
Consistency: - This rule states that only valid data should be written to database. Any invalid data should roll back the whole transaction. If the transaction executes successfully then it should take database from one state which is consistent to other state which is also consistent.
|
Java Training: - How will you explain Page directives?
Page directive is used to define page attributes the JSP file. Below is a sample of the same:-
To summarize some of the important page attributes:-
Import: - Comma separated list of packages or classes, just like import statements in usual Java code.
Session: - Specifies whether this page can use HTTP session. If set "true" session (which refers to the javax.servlet.http.HttpSession) is available and can be used to access the current/new session for the page.
If "false", the
|
Java Training: -Explain implicit EL (Expression Language) objects in JSP?
Following are the implicit EL (Expression Language) objects:-
Page Context: The context for the JSP page.
Provides access to various objects for instance:-
servletContext: The context for the JSP page's servlet and any web components contained in the same application.
session: The session object for the client.
request: The request triggering the execution of the JSP page.
response: The response returned by the JSP page. See Constructing Responses.
In addition, se
|
Java Training: -Elaborate Garbage collector in Java?
Garbage collection is the process of automatically freeing objects that are no longer referenced by the program. This frees the programmer from having to keep track of when to free allocated memory, thereby preventing many potential bugs. Thus making programmers more productive as they can now put more effort in coding rather than worrying about memory management.
The only disadvantage of garbage collector is it adds overheads. Because the JVM (Java virtual machine) has to keep a constant tr
|
Java Training: -Show Service Loader in Java?
What is Service loader in Java?
Service Loader is a new class added in Java 1.6 and it provides good means of developing loosely coupled application.
It allows us to link an interface to a particular implementation at run time based on configuration thus providing us with loose coupling
It also provides a sort of Dependency Injection (DI) though not as powerful as Spring framework but does provide a good facility in case you don’t require a full blown DI feature.
Also various design
|
Java Training: -How will you explain JDBC (Java Database Connectivity) and its different section?
JAVA interacts with database using a common database application programming interface called as JDBC. JDBC allows a developer to write applications that is database independent. So the developer will be interacting with JDBC API rather than getting in to complications of the database.JDBC allows you to write Java code, and leave the platform (database) specific code to the driver. JAVA was designed to be platform independent and JDBC takes java one step ahead making java database code database
|
Java Training: -Elaborate taglib directives?
Taglib are also termed as JSP tag extensions. They provide a way of encapsulating reusable functionality on JSP pages. One of the biggest drawbacks of scripting environments such as JSP is that it's easy to get carried away without thinking about how it will be maintained and grown in the future. For example, the ability to generate dynamic content by using Java code embedded in the page is a very powerful feature of the JSP specification. Custom tags allow such functionality to be encapsulated
|
Java/Servlets interview questions: -Mention the concept of SSI(Server Side Includes)?
Server Side Includes (SSI) are commands and directives placed in Web pages that are evaluated by the Web server when the Web page is being served. SSI are not supported by all web servers. So before using SSI read the web server documentation for the support. SSI is useful when you want a small part of the page to be dynamically generated rather than loading the whole page again.
Below is the code for SSI which needs to be inserted in between the HTML tags.
Here the CODE attribute spec
|
Java/Servlets interview questions: -Explain differences between getSession(true) and getSession(false)?
Session's can be considered as a series of related interactions between client and the server that take place over a period of time. Because HTTP is a stateless protocol these series of interactions are difficult to track. That’s where we can use HttpSession object to save in between of these interactions so that server can co-relate between interactions between clients.
Figure: - Session code walkthrough
Above is the code snippet which displays session data. Step1 returns an HttpSes
|
Java interview questions: - What do you mean by cookies?
Cookies are piece of data which are stored at the client’s browser to track information regarding the user usage and habits. Servlets sends cookies to the browser client using the HTTP response headers. When client gets the cookie information it’s stored by the browser in the client’s hard disk. Similarly client returns the cookie information using the HTTP request headers.
Figure: - Cookies in action
Figure: - Cookies code walkthrough
Above is a simple snippet which shows ho
|
Java interview questions: - Explain why is HTTP protocol called as a stateless protocol?
A protocol is stateless if it can remember difference between one client request and the other. HTTP is a stateless protocol because each request is executed independently without any knowledge of the requests that came before it.
Figure: - HTTP Protocol in action
Above is a pictorial presentation of how a stateless protocol operates. User first sends “request1” and server responds with “response1”. When the same user comes back with “request2” server treats this as new user and has
|
Java/servlets interview questions: - Can you explain Servlets and its lifecycle?
Servlets are small program which execute on the web server. They run under web server environment exploiting the functionalities of the web server.
Servlet life cycle
Figure: - Servlet Life cycle
There are three methods which are very important in servlet life cycle i.e. "init”, "service" and "destroy". Server invokes "init ()" method when servlet is first loaded in to the web server memory. Servlet reads HTTP data provided in HTTP request in the "service ()" method. Once initia
|
Java interview questions: - How will you explain Native Interface in JAVA?
JNI is a mechanism by which you can invoke method written in native language like C and C++. Native languages allow you to use a platform specific feature which is not in control of java language. For instance if you want java to interact directly with some specific type of hardware it will extremely difficult to achieve it. So you can write a C code and declare its native methods and call the same in Java.
Figure: - JNI in action
The above figure indicates how JVM interacts with JNI
|
|