WEBVTT

00:00.290 --> 00:00.890
Hi everyone.

00:00.890 --> 00:02.180
Welcome back to this tutorial.

00:02.180 --> 00:08.540
In this tutorial, we will code and explore some of the issues that we might face with the introduction

00:08.540 --> 00:10.250
of multiple interfaces.

00:10.280 --> 00:14.450
In order to demonstrate this, I'm going to create an interface.

00:16.270 --> 00:17.710
All interface for.

00:19.610 --> 00:20.210
And.

00:21.140 --> 00:26.750
We take a look at it Interface one and interface four have the similar methods.

00:26.750 --> 00:27.380
Right?

00:27.410 --> 00:33.290
I'm going to create an implementation class called client one four.

00:33.440 --> 00:33.620
Okay.

00:33.620 --> 00:38.090
This is going to implement interface one and interface four.

00:38.120 --> 00:41.180
That's the reason why I named it as client one four.

00:44.660 --> 00:46.520
So this is going to implement.

00:47.810 --> 00:51.590
The interface one and interface for.

00:53.240 --> 00:57.860
As soon as I do it, we take a look at it is giving some compilation issue.

00:58.770 --> 01:07.650
.14 inherits unrelated default methods for method A from types interface one and interface for.

01:07.680 --> 01:13.170
The reason why we get this compilation issue is that it has a method called.

01:13.200 --> 01:14.040
Method A.

01:14.310 --> 01:21.420
Basically, interface one has a method called method A and interface four also has a method called method

01:21.450 --> 01:24.090
A with a similar kind of method signature.

01:24.120 --> 01:31.260
Now Java is so confused and it is not sure which method it needs to resolve when we call that.

01:31.260 --> 01:38.370
So the actual expectation in these kind of scenarios is that you have to implement that method basically

01:38.370 --> 01:39.060
not implement.

01:39.060 --> 01:42.990
You have to override that method in the actual implementation class.

01:42.990 --> 01:46.810
That's the only way to resolve this kind of issues.

01:46.830 --> 01:52.470
So this is something which you have to keep in your mind whenever you are implementing interfaces.

01:52.500 --> 01:59.590
If both the interface have a similar method and the only way to solve these kind of issues is to implement

01:59.590 --> 02:03.130
that method in the implementation class itself.

02:03.860 --> 02:08.300
And thus I'm going to name this one as client.

02:09.250 --> 02:10.750
One for class.

02:10.840 --> 02:12.400
Now let's call this one.

02:12.580 --> 02:13.840
Create an instance.

02:14.740 --> 02:18.280
Line one for line, one for equal to new client one.

02:18.280 --> 02:21.100
For now, call the method.

02:23.580 --> 02:24.570
Wanna run this one?

02:26.640 --> 02:30.180
You take a look at it, it printed the result as expected.

02:30.480 --> 02:33.090
So this is one thing which you have to keep in your mind.

02:33.120 --> 02:40.860
If you have two methods of similar method signature, then you have to override the similar method in

02:40.860 --> 02:42.450
your implementation class.

02:42.690 --> 02:44.650
With this, we came to the end of this tutorial.

02:44.670 --> 02:45.810
Thank you for watching.
