Serialization Java Interview Questions – Set 03

Why doesn’t Collection extend Cloneable and Serializable From Sun FAQ Page: Many Collection implementations (including all of the ones provided by the JDK) will have a public clone method, but it would be mistake to require it of all Collections. For example, what does it mean to clone a Collection that’s backed by a terabyte … Read more

Beans Java Interview Questions – Set 03

What are the different types of IoC (dependency injection There are three types of dependency injection: Constructor Injection(e.g. Spring): Dependencies are provided as constructor parameters. Setter Injection(e.g. Spring): Dependencies are assigned through JavaBeans properties (ex: setter methods). Interface Injection(e.g. Avalon): Injection is done through an interface. In your experience, why would you use Spring framework … Read more

Hibernate Java Interview Questions – Set 03

What is a SessionFactory? Is it a thread-safe object SessionFactory is Hibernate’s concept of a single datastore and is threadsafe so that many threads can access it concurrently and request for sessions and immutable cache of compiled mappings for a single database. A SessionFactory is usually only built once at startup. SessionFactory should be wrapped … Read more

JSP Java Interview Questions – Set 03

Name one advantage of JSP over Servlets Can contain HTML, JavaScript, XML and Java Code whereas Servlets can contain only Java Code, making JSPs more flexible and powerful than Servlets. However, Servlets have their own place in a J2EE application and cannot be ignored altogether. They have their strengths too which cannot be overseen. What … Read more

Servlet Java Interview Questions – Set 03

What is connection pooling?- With servlets, opening a database connection is a major bottleneck because we are creating and tearing down a new connection for every page request and the time taken to create connection will be more. Creating a connection pool is an ideal approach for a complicated servlet. With a connection pool, we … Read more

JDBC Java Interview Questions – Set 03

What does setAutoCommit(false) do A JDBC connection is created in auto-commit mode by default. This means that each individual SQL statement is treated as a transaction and will be automatically committed as soon as it is executed. If you require two or more statements to be grouped into a transaction then you need to disable … Read more

Multi Threading Java Interview Questions – Set 03

What is garbage collection The runtime system keeps track of the memory that is allocated and is able to determine whether that memory is still useable. This work is usually done in background by a low-priority thread that is referred to as garbage collector. When the gc finds memory that is no longer accessible from … Read more

RMI Java Interview Questions – Set 02

What is the difference between SOA and a Web service SOA is a software design principle and an architectural pattern for implementing loosely coupled, reusable and coarse grained services. You can implement SOA using any protocols such as HTTP, HTTPS, JMS, SMTP, RMI, IIOP (i.e. EJB uses IIOP), RPC etc. Messages can be in XML … Read more

Serialization Java Interview Questions – Set 02

Does setting the serialVersionUID class field improve Java serialization performance? Declaring an explicit serialVersionUID field in your classes saves some CPU time only the first time the JVM process serializes a given Class. However the gain is not significant, In case when you have not declared the serialVersionUID its value is computed by JVM once … Read more

Beans Java Interview Questions – Set 02

What are the four types of J2EE modules? Application client module Web module Enterprise JavaBeans module Resource adapter module How can I set a cookie in JSP?- response. setHeader(”Set-Cookie”, “cookie string”); To give the response-object to a bean, write a method setResponse (HttpServletResponse response) – to the bean, and in jsp-file:<% bean. setResponse (response); %> … Read more