Interview Question: What is lazy loading?

By: Ash  

Question:What is lazy loading?

Answer:

Lazy loading means not creating an object until the first time it is accessed. Lazy loading typically looks like this:
public class Example {
private Vector data = null;
public Vector getData() {
if (this.data == null) {
this.data = new Vector();
// Load data into vector …
}
return this.data;
}
}
This technique is most useful when you have large hierarchies of objects (such as a product catalog). You can lazy-load subordinate objects as you navigate down the hierarchy, and thereby only create objects when you need them.

 

 

 

 



Most Viewed Articles (in Interview )

Explain the new Features of JDBC 2.0 Core API?

How to define an Abstract class?

Interview Question: Can i map more than one table in a CMP?

Interview Question: What is difference between EJB 1.1 and EJB 2.0?

What do you understand by JSP Actions?

What is the difference between jsp:include page and @ include file?

Interview Question: What is the difference between EAR, JAR and WAR file?

Interview Question: What is the difference between sessioncontext and entitycontext?

Interview Question: What are the optional clauses in EJB QL?

Interview Question: Is Decorator an EJB design pattern?

What are implicit Objects available to the JSP Page?

Interview Question: Can I invoke Runtime.gc() in an EJB?

Interview Question: What is Local client view in EJB?

Interview Question: Why does EJB needs two interfaces(Home and Remote Interface)?

Interview Question: What is the difference between ejbCreate() and ejbPostCreate?

Latest Articles (in Interview)

Comment on this tutorial