An abstract method can be implemented in many different ways.
If a parent defines an abstract method, the child class is forced to override its.
In this lesson, you will define an abstract method.
An abstract method forces a child class to override its.
Create an abstract method if you want to force every child class to override its.
You can create an abstract method by specifying the level of access.
That it's abstract, which means it can be implemented in many different ways.
It's not concrete.
The return type and parameters.
So as per the requirements, every product needs to be folded before being sold to a customer.
So we need to somehow force every class that is a child of product to implement the fold method.
So right here, we're going to define a public abstract method.
And we're going to force every child past the A method that returns void called foaled, and that receives
no parameters.
Now, an abstract method doesn't have a body because it's not concrete, abstract means the method can
be implemented in many different ways and each child class is going to have its own way of overwriting
this method.
Shirts have one way of being folded and pens up another way.
So inside the short class, notice we've got a compilation error.
We're being forced to override the Fulda method.
And to fold a t shirt first, I'll put four print statements.
First, you have to lay the shirt on a flat surface.
Fold the shirt sideways.
Bring the slaves in.
And fold from the bottom up.
OK, now inside the pants class, once again, notice we get a compilation error, we're being forced
to override the fold method.
And default pants hold pants upright.
Fold one leg over the other.
Fold pens from the bottom in thirds.
And that's it.
Each child overrides the four day method and provides its own implementation.
Let's test everything out in main.
Called Foaled from Schertz Runit.
Called Foaled from Pentz Runit.
And good.
An abstract, a method forces a child class to override its.
You should create an abstract method if you want to force every child class to override its.
You can read an abstract method by specifying the level of access.
That it's abstract, abstract means the method can be implemented in many different ways and each child
class is going to have its own way of overriding this method.
The return type and parameters.