5 - Class & Objects
5 - Class & Objects
CHAPTER - V
CLASS
• Class is the collection of objects.
• Class is not a real-world entity. It is just a template or blueprint or prototype.
• Class cannot occupy memory.
Syntax: eat() sleep()
access-modifier class ClassName
{
Animal
o Methods
o Constructors
o Fields
o Blocks dog cat
o Nested class…
}
java.util.ArrayList; java.util.*;
Explicit import is always recommended to In case we are importing implicitly, all the
improve the readability of the program. package and interfaces are available but not
the sub packages.
PACKAGES
• A group of related classes & interfaces are • Advantages:
grouped into a separate unit. • Naming conflicts may be resolved – e.g. Date
in java.sql & java.util
• Thus package is a encapsulation mechanism.
• Modularity of the application may be improved.
____________________________ • Maintainability of the application may be
Good programming practice is to create every improved.
class and interface as part of a package. • It provides security to all the components.
THANK YOU