Programming Tutorials

Interview Question: What is lazy loading?

By: Ash in Interview Tutorials on 2008-08-13  

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:

import java.util.Vector;

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.

 

 

 

 





Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in Interview )

Interview Question: What are the call back methods in Entity bean?

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

What is the difference between Session Bean and Entity Bean?

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

Interview Question: What is ActionServlet?

Interview Question: What is lazy loading?

What is bean managed transaction?

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

Is Iterator a Class or Interface? What is its use?

Interview Question: What is Remote client view?

Interview Question: What is Deployment descriptor?

Interview Question: Do ActionForms have to be true JavaBeans?

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

What do you understand by JSP Actions?

What are the life-cycle methods of JSP?

Latest Articles (in Interview)