Modularization in Java
1. Java Package
A package is a group of related classes and interfaces. It provides modularity, reuse, and prevents
name conflicts.
Types:
• Built-in Packages: [Link], [Link], [Link], etc.
• User-Defined Packages.
2. Importing Packages
Used to access classes from other packages.
Examples:
import [Link];
import [Link].*;
3. Static Methods
Static methods belong to the class and can be called without creating an object.
4. Static Fields
Static fields are shared by all objects of the class.
5. Scope of Declaration
• Local Variables – inside methods
• Instance Variables – each object gets its own copy
• Static Variables – shared by all objects
• Parameter Variables – defined in method signature
6. Method Overloading
Same method name but different parameters.
Example:
add(int, int)
add(double, double)
7. Java API Packages
Common Packages:
• [Link] – core classes
• [Link] – collections and utilities
• [Link] – input/output
• [Link] – networking
• [Link] – GUI components