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.

 

 

 

 


Archived Comments

1. Valentin
View Tutorial          By: payday loans direct lender at 2012-06-26 15:59:07


Most Viewed Articles (in Interview )

Interview Question: How do I install Struts?

Interview Question: What is the difference between find and select methods in EJB?

What is the difference between interface and abstract class?

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

Interview Question: What is re-entrant. Is session beans reentrant. Is entity beans reentrant?

Interview Question: What is Message Driven Bean?

Interview Question: What about JSTL and JavaServer Faces ?

What are the call back methods in Session bean?

What is expression in JSP?

What types of comments are available in the JSP?

What do you understand by JTA and JTS?

Interview Question: Write code of any Action Class?

What is the difference between Session Bean and Entity Bean?

What are types of J2EE clients?

Differentiate between .ear, .jar and .war files.

Latest Articles (in Interview)

Comment on this tutorial