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
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
What do you understand by JTA and JTS?
What do you understand by Synchronization?
Name the containers which uses Border Layout as their default layout?
What is bean managed transaction?
What are the call back methods in Session bean?
Can Entity Beans have no create() methods?
What is the difference between JTS and JTA?
What is difference between Java Bean and Enterprise Java Bean?
What is J2EE Connector architecture?
Tell me something about J2EE component?