Interview Question: What is lazy loading?

By: Ash Printer Friendly Format    

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 )

Question: What is a Hidden Comment in JSP?

What is Deployment Descriptor?

Interview Question: What is Action Class?

Interview Question: Is it possible to share an HttpSession between a JSP and EJB? What happens when I change a value in the HttpSession from inside an EJB?

Question: What is an output comment in JSP?

What is J2EE?

Name the containers which uses Border Layout as their default layout?

Explain the Encapsulation principle.

Explain the different forms of Polymorphism.

What are all the different scope values for the tag?

Interview Question: What is Struts Validator Framework?

Interview Question: How does Struts work?

Interview Question: If the framework doesn't do what I want, can I request that a feature be added?

Interview Question: What is EJB container?

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

Latest Articles (in Interview)

Comment on this tutorial