Programming Tutorials

Interview Question: What is lazy loading?

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

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:

import java.util.Vector;

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.





Add Comment

* Required information


No comments yet. Be the first!

Most Viewed Articles (in Interview )

The output of System.out.println(5<<2) in Java

Interview Question: What is lazy loading?

Interview Question: What is Struts?

Interview Question: Where can I get help with Struts?

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

Interview Question: What is Remote client view?

What are implicit Objects available to the JSP Page?

What is the difference between Session Bean and Entity Bean?

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

What do you understand by a J2EE module?

Interview Question: What is the difference between JavaBean and EJB?

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

Interview Question: What is Action Class?

What do you understand by JTA and JTS?

Question: What is an output comment in JSP?

Latest Articles (in Interview)