INTRODUCTION TO OOP
Object-Oriented Programming (OOP) organizes programs using objects. Objects contain data
(attributes) and behavior (methods).
WHY USE OOP
• Organized code
• Easy maintenance
• Reusability
• Real-world modeling
ADVANTAGES OF OOP
• Code Reusability
• Modularity
• Easy Maintenance
• Data Security
• Real-world Representation
CLASS AND OBJECT
Class – blueprint of an object
Object – instance of a class
FOUR PILLARS OF OOP
Encapsulation, Abstraction, Inheritance, Polymorphism
ENCAPSULATION
Hides data using private variables and public getter and setter methods.
ABSTRACTION
Shows only important details using abstract classes and interfaces.
INHERITANCE
Allows a class to inherit properties and methods from another class.
POLYMORPHISM
Same method name but different behavior.
JAVA FILE HANDLING
Used to create, read, write, append, and delete files.
READING FILES
Scanner, FileReader, BufferedReader
WRITING FILES
FileWriter, BufferedWriter, PrintWriter
APPENDING AND DELETING FILES
Append using FileWriter(true). Delete using delete() method.
JAVA EXCEPTIONS
Exceptions are runtime errors that interrupt normal program execution.
TYPES OF EXCEPTIONS
Checked Exceptions and Unchecked (Runtime) Exceptions
EXCEPTION HANDLING KEYWORDS
try, catch, finally, throw, throws
END
Good luck on your Java exam!