WEBVTT

00:00.000 --> 00:04.880
In this lesson, we will refresh the foundational ideas of object-oriented programming,

00:04.880 --> 00:08.000
inheritance, encapsulation, and polymorphism.

00:09.520 --> 00:14.640
These concepts form the base of Java programming and help us write cleaner, reusable,

00:14.640 --> 00:18.320
and structured code. Let's begin with inheritance refresher.

00:19.120 --> 00:23.600
In Java, a class can extend another class and reuse its properties and methods.

00:24.080 --> 00:26.080
This is known as single inheritance.

00:26.400 --> 00:30.720
For example, here the dog class inherits from animal.

00:31.280 --> 00:36.560
This makes our code reusable and easier to maintain. We also recall the difference between

00:36.560 --> 00:42.080
public and private members. Public members can be accessed anywhere, while private members are

00:42.080 --> 00:48.320
accessible only inside the same class. This leads us to our next concept, encapsulation.

00:48.880 --> 00:53.600
Incapsulation means protecting data by keeping variables private and accessing them through

00:53.600 --> 00:59.760
getters and setters. This helps maintain class invariance and prevents accidental misuse of data.

01:01.600 --> 01:08.160
Example, here the age variable is hidden and we control how it is set. This is also called

01:08.160 --> 01:15.600
data hiding. Incapsulation ensures the object always stays in a valid state. Polymorphism simply

01:15.600 --> 01:23.040
means one action, many forms. There are two main types, method overloading, same method name,

01:23.040 --> 01:29.200
different parameters, method overriding, same method name and parameters, but implemented

01:29.200 --> 01:35.920
differently in subclasses. Java decides at runtime which version of the method to run.

01:36.560 --> 01:42.400
This is runtime polymorphism. Polymorphic references allow us to write general code

01:42.400 --> 01:49.280
that works with multiple object types. In this session, we reviewed how Java uses single

01:49.280 --> 01:56.000
inheritance. Why encapsulation protects data? How polymorphism allows flexibility and cleaner

01:56.000 --> 02:02.800
code? And how small hands-on exercises can help reinforce these ideas? These OOP principles

02:02.800 --> 02:08.080
form the backbone of advanced Java programming and help students write powerful, organized,

02:08.080 --> 02:10.080
and efficient programs.

