Hi this is really hard.
Once again welcome to the next video of this Carleen for now Mendel's.
In this video we will talk about voter interfaces in case of Cartland.
So let us first check out the practical example and then the Tuti.
So here insert the intelligent ID.
This is the example that we took in the previous video made about the abstraction in Gears of Cartland.
Now suppose if I change this abstract open class to let's see interface and now the interface is not
a class.
Always remember this.
It is something like a listener that you want some service such as on click of button.
Something should happen on touch of a keyboard something should happen.
So in that case the listener is actually the interface right.
You want some short term or temporary service.
So in that case we create the interface as for example in Android.
Suppose someone click on a button.
So on click of a button something should happen right.
So we implement the on click method in case of Android.
So that is the main purpose of interface in case of Cartland as well.
So here let us change the name of interface Let's see might in Duffys listener.
Right.
And now here Vontae What do you define inside an interface.
Is actually by default abstract in nature such as that.
Let's say name string.
Well it should not be name here because we are using the interface but it's a variable name so let it
be named by default right now by default whatever you declare inside the interface is actually abstract
and also open in nature because abstract variables and methods are by default open in nature that we
saw in the previous review right.
And this abstract is redundant.
So we need to remove it as well and also abstract keywords and also abstract methods and also the variables
should not contain some be FOID value like here.
Let's say I mean name like this.
So the abstract variables should not contain some initialized value.
It should be a declaration like this so that it is removed as well because it is redundant.
So here I have simply written a comment statement properties in gifts or interface or abstract Bideford
right.
And now suppose let us define a function.
Let's see it or let's say on Glee.
And here suppose if I define a body.
Now if you define a body then this method is actually a normal function which is actually public in
nature.
But in this case it is not final in nature because in case of an Duffys nothing is final.
Everything is open in nature.
So this method is basically is by default open in nature.
It is not final.
So always remember in is in Duffys nothing is final.
Everything is open in nature.
So let me write a line for you.
So the normal methods are public and open Bideford not final.
Always remember.
And now here this public and open keyword are redundant.
So let us remove it and now let us define one more method.
Let's see a function of.
On page on pecial for which something should happen.
Now here if I define here the body and declare here abstract then the compiler is again not happy because
the abstract metrics cannot contain the body right.
So here either I have to remove this or I have to remove this from here.
But but I've tried this method to be abstract in nature right.
So here they really do is I would simply remove the body now since it is abstract in nature.
So you have the compulsorily or what I did inside the class that implements this interface.
And now this was all about the properties inside the interface abstract methods and also the normal
matters.
And now suppose I have a class of Indian.
Let's see let's remove it here and there doesn't modify the code.
The class of bargain.
Now suppose if I want to implement this in Duffys for this button so what I will do is I would simply
use Blasberg then go alone then simply use my interface listener.
Now this is actually the interface.
Suppose you want to inherit some classic legacy person then for that you need to use the syntax isn't
followed by the primary constructor.
As we did in the previous videos.
But if you want to implement the interface then you just have to specify galloon forward by interface
name.
There is no primary constructor here.
Just because the interface cannot be instantiated.
So here I've simply written the command line.
You cannot create the instance of the abstract class.
Let's make it in Duffys so the interface is similar to the abstract class cannot be instantiated.
What I'm talking about is inside the main method.
You simply cannot define that.
Let's see may object equal to might in Duffys list.
You can not do it because my interface is listen that can not contain a constructor as well.
It is just an interface not a class.
So always remember it is similar to Abchurch classes.
The interface cannot be instantiated as remove it.
And now here Legos move the person as well.
So this is the syntax to get all the properties of this.
Mike Duffy is listed there inside the class of button.
And now let's call it my button as of now just to avoid any confusion.
And now here it shows some error that if you are using the interface here then you must override this
abstract method that is on edge.
And also this abstract variable name.
And now here this abstract abstract keyword is redundant.
So again metrics in interface are abstracted by the.
So to rectify this error we need to override this variable name and also function on stage because they
are abstract in nature.
So I will simply override.
Let's see what I divide.
Name other types of string and simply assign a default value with a dummy name.
It is totally up to your choice.
And now let us all read this abstract method as well.
Function on page.
So here I will simply use overdyed keyword SPEEs function.
Let's see.
On page so here the intelligent Id simply creates a placeholder to do for us.
I simply define our own code right like this.
Now coming to this point function on click.
Now this function on click is not abstract in nature because it has a method and body so it is actually
behaving like a normal method.
So if you've warned it is totally your choice.
You override that method or not.
If you want you can also override it.
It is totally up to your choice right.
And if you want you can also call the support implementation of this method like Supernaut on click
method.
So as of now I don't want it.
So that does remove it.
You may or may not override this method.
Right because this is a normal method.
Now inside the main method what I'm going to do is simply create the instance of this class of my button
because this my button is actually of the type of plus so began instantiated value.
Let's see.
And after this I would simply call my button and Dorte.
Let's say on that great.
So this was simply too good.
This mentored president he had on pitch and also I will call my Verdon dark legacy on Glick.
And this was simply very good this method.
But as here.
This on klick.
Now let us define our record here.
Let's see then.
Martin was just.
And he had Franklin as well.
Burton was right.
And I suppose if I had the court right now then these two statements is simply going to print the was
just and also bartend was plugged in the output gunsel.
So here in the output we get burdened was plagued button was dust and leaked like this.
And now suppose inside the on click method.
Suppose I have some print statement.
Let's see Brant line on click interface boards right like this.
So this is the opening line statement inside the on click method.
Now suppose I want to print this statement as well.
So far that what I really do is insert the limiter method inside of my Button class.
What we do is I would simply use the super keyword superdog and I I'll simply call on click Metford.
So this will simply Paragould the superclass method that is this one.
Now remember this is not the class right but still we are inheriting all the properties of my in Duffys
listener.
Inside my button class.
So they're just not called so in the output we get but then was just then only in Duffys scored but
it was scored and then button was clicked.
So this is how we call the superclass method.
Right.
Like we have done here superdog on click.
Now if you want to and also remove this on click chord here.
It will show no error.
Right.
But if you remove this on touch method then the compiler is not happy because this on this method is
actually abstract in nature.
So you need to override it.
Anyhow here inside there did a plus.
And now suppose I have one more in Duffys.
So let us copy this in Duffys.
My second in Duffys listener Ahlers lairds trimmed down the name.
My second in Duffys right and now inside both the interface.
Let's just modify our code.
So here I will simply remove the variable name and also here name.
And now I will simply convert this function on edge into the normal method.
So I would simply define the body as.
Let's see if Parentline aren't actually scored from my second interface on actual scored from my and
in Duffys.
Now similarly here I will.
So here I have simply mortified my chord inside my industrious listener I am having on Dutch abstract
matters without any body Nasima.
I am having in inside my second interface.
But it is not behaving as a normal method.
It is no longer abstract method.
Now this method and this method of yours truly seem right.
So suppose I want to implement both the list inside my board and clothes.
So what we do is this is our first listener and then I will simply give a coma and then implement my
second interface like this right.
And here it is.
Will this statement.
And now let just remove the chord as well.
Here and now here it shows some error that you need to implement the abstract method so simply place
it and go implement the members and English sure you two options.
Mike Gardley in my interface listener.
My second Duffys.
We need to override this on Bush method which is actually abstract in nature so ask but our expectation
that EDID should have been gone.
But here if you notice the error is not gone.
But as per the rule we have simply overridden this abstract method no rest of the methods are actually
normal amateur's that should be optional to override such as on CLI mattered and also on the method
of the second interface.
But here we are using to interface now these two dollface have two amateur's on edge and on Glee and
in one of the keys we have on Desch mentored as abstract.
So we need to override this on page Metford complicity inside of my button plus but Varda bold on click
mattered.
This is normal my third here and this is again the normal method.
No aspart at all.
If there are two interface and there are two normal amateur's all of the same name inside the interface
then you need to override that method as well.
So here I have to simply press or enter and simply inherit the on click method here like this.
So this rectifies our error.
Right now supperless.
I created the instance of my button like this and call my button on stage and my but and on click right
now if I simply want to call this button dord on touch method then it will simply go into pretty good
this method down the side inside the main button plus and if I want to trigger a superclass method then
I would simply use superdog on page.
So this statement is similar to good.
The on page method here because this is the normal method and this is the abstract method without any
body.
So there is no point of this method being called because this method don't have any code.
And here I have some code right.
So this statement will simply trigger the superclass on Bash method of my second interface that has
some Vardi.
And now suppose this statement is executed Mayberg and or unclick.
So this will simply trigger this local method off on leg press and inside my button plus.
So here if I call Lexie's soup it dawned on click.
So what will happen it will simply show some error because the compiler will be confused.
That are superdog on click Metford is actually present in boot that case that is in this interface and
also inserted this in Duffys so it gets simply confused which meant to call.
Right so in that case we have a solution here.
We can simply define super.
I simply pass the name of the Duffys super.
My interface listener got on click and again if you want to call this Mazak an interface on click Metford
then you can simply call super and simply pass the name of my second interface Dorte on click.
Right so these two statements are simply going to trigger the respective on click methods present inside
the interface.
Here and here like this.
So always remember this while you are using there to interface and if the interface contains the same
third name.
So how to handle that situation.
I just showed you in this example.
So this was all about the practical example.
No need to jump back to the tutor Dickel example.
So the interface can contain both normal methods and also abstract methods.
So always remember this.
It can contain normal as well as abstract methods but in gesso property they can contain only abstract
property that is you cannot initialize any variable inside the interface.
Novels are going forward.
The indices are not a class.
So do remember this and now similar to the abstract class.
You can not create the instance of the interface because the interface is not a class.
It is something different thing that only provides a short term sort of his such as a button click on
touch when you check the checkbox when you try to open their dialog box.
And something like that.
So it simply provides a short them service right there in Duffys.
So this was all about the interface in case of Cartland.