Interview Question: What is lazy loading?

By: Ash Viewed: 1415 times  Printer Friendly Format    

Question:What is lazy loading?


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 ( == null) { = new Vector();
// Load data into vector …
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 )

What is Deployment Descriptor?

What is Collection API?

Interview Question: How do I install Struts?

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

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

Question: How is the MVC design pattern used in Struts framework?

Why J2EE is suitable for the development distributed multi-tiered enterprise applications?

Explain the user defined Exceptions?

What is the difference between jsp:forward and response.sendRedirect(url),?.

What is JSP Scriptlet?

Interview Question: How is the MVC design pattern used in Struts framework?

Interview Question: Who makes the Struts?

Interview Question: Why do we need Struts?

Interview Question: Where can I get a copy of Struts?

Interview Question: Does Struts include its own unit tests?

Latest Articles (in Interview)

Comment on this tutorial