WEBVTT

00:00.000 --> 00:05.600
In Java, abstraction helps us hide unnecessary details and show only what is important.

00:07.840 --> 00:11.600
It makes programs easier to understand, maintain, and extend.

00:12.800 --> 00:17.680
One of the main ways Java supports abstraction is through abstract classes and interfaces.

00:18.640 --> 00:22.160
Abstract classes represent concepts that cannot be created directly.

00:22.800 --> 00:26.240
For example, think of a general idea like a vehicle.

00:26.960 --> 00:31.200
You cannot create a generic vehicle, but you can create a car or bike.

00:31.200 --> 00:34.080
That is why an abstract class cannot be instantiated.

00:35.280 --> 00:40.800
Abstract classes allow you to write common code while still forcing some methods to be implemented

00:40.800 --> 00:47.360
by subclasses. Here, every vehicle must define how it drives, but they all share the ability to

00:47.360 --> 00:54.160
store a model name. Abstraction ensures cleaner structure. Shared behavior across related classes,

00:54.720 --> 01:00.560
hiding complex implementation details. This prepares us to explore deeper differences between

01:00.560 --> 01:08.240
abstract classes and interfaces. For example, a trucker-bite class can extend vehicle and provide

01:08.240 --> 01:15.840
their own version of drive. Abstract classes also allow instance variables, constructors,

01:15.840 --> 01:21.120
protected data. These features make them useful when multiple subclasses share state.

01:21.120 --> 01:28.480
Interfaces define a contract. They specify what a class must do without specifying how it is done.

01:30.000 --> 01:35.840
Before Java 8, interfaces could only have abstract methods, but now they can also include

01:35.840 --> 01:42.400
default methods. Static methods. This allows interfaces to evolve without breaking old code.

01:44.560 --> 01:50.000
Any class that implements driveable must define how it drives, but it automatically gains the

01:50.000 --> 01:56.080
honk behavior. Interfaces are also key for multiple inheritance of type. A class can implement

01:56.080 --> 02:02.880
multiple interfaces, allowing flexible and modular designs. Interfaces are best used when no shared

02:02.880 --> 02:09.360
state is required. Only method signatures need to be defined. Multiple unrelated classes need

02:09.360 --> 02:17.600
similar capabilities. Use an abstract class when multiple classes share common code. You need

02:17.600 --> 02:24.720
shared variables or state. A base class defines common behavior. Use an interface when you want

02:24.720 --> 02:30.800
a strict contract. Multiple classes need the same capabilities. Multiple inheritance is required.

02:32.560 --> 02:38.800
In this session, we learned what abstract classes are and why they cannot be instantiated.

02:38.800 --> 02:45.120
How interfaces act as contracts for behavior. How Java 8 introduced default and static methods

02:45.120 --> 02:49.920
in interfaces. How to choose between an abstract class and an interface.

02:51.920 --> 02:57.520
Abstraction through abstract classes in interfaces allows Java programs to be flexible,

02:57.520 --> 03:03.680
organized, and easier to maintain. Mastering these concepts prepares students for more advanced

03:03.680 --> 03:06.720
OOP techniques and real-world software development.

