PROGRAMMING IN JAVA ( U23CAT407 )
[Link] TO OBJECT-ORIENTED PROGRAMMING
OOP stands for Object-Oriented Programming.
Procedural programming is about writing procedures or methods that perform
operations on the data, while object-oriented programming is about creating objects
that contain both data and methods.
Object-oriented programming has several advantages over procedural programming:
OOP is faster and easier to execute
OOP provides a clear structure for the programs
OOP helps to keep the Java code DRY "Don't Repeat Yourself", and makes the
code easier to maintain, modify and debug
OOP makes it possible to create full reusable applications with less code and
shorter development time
Key Features of OOP in Java:
Structures code into logical units (classes and objects)
Keeps related data and methods together (encapsulation)
Makes code modular, reusable and scalable
Prevents unauthorized access to data
Follows the DRY (Don’t Repeat Yourself) principle
I. CLASSES AND OBJECTS
A Class is a user-defined blueprint or prototype from which objects are
created. It represents the set of properties or methods that are common to all
objects of one type. Using classes, you can create multiple objects with the
same behavior instead of writing their code multiple times. In general, class
declarations can include these components in order:
Modifiers: A class can be public or have default access
Class name: The class name should begin with the initial letter capitalized
by convention.
Body: The class body is surrounded by braces, { }.