#67 More on Interfaces in Java
Vložit
- čas přidán 8. 09. 2024
- Check out our courses:
Enterprise Java Spring Microservices: go.telusko.com...
Coupon: TELUSKO10 (10% Discount)
Master Java Spring Development : bit.ly/java-sp...
Coupon: TELUSKO20 (20% Discount)
Udemy Courses:
Java:- bit.ly/JavaUde...
Spring:- bit.ly/SpringU...
Java For Programmers:- bit.ly/javaPro...
For More Queries WhatsApp or Call on : +919008963671
website : courses.telusk...
In this lecture we will learn:
- Implementation of multiple interfaces
- Inheritance in between interfaces
- Method calling of an interface
#1
- We can have a class implementing multiple interfaces.
class B implemets A,X
{
}
(here, A and X are two different interfaces)
- Implementation of all the methods that are present in those interfaces should be given in a class.
- Inheritance is also valid in between interfaces.
- Inheritance can be achieved in between interfaces by using the extend keyword.
- Whenever you create a reference of an interface and create an object of a class, then you can only call those methods by that reference that are present in that interface of which the refernce is created.
- Methods of another interface can be called by using another reference variable for that interface with the object of a class.
#2
*
class - class - extends
class - interface - implements
interface - interface - extends
Github repo : github.com/nav...
Java:- bit.ly/JavaUde...
Spring:- bit.ly/SpringU...
More Learning :
Java :- bit.ly/3x6rr0N
Python :- bit.ly/3GRc7JX
Django :- bit.ly/3MmoJK6
JavaScript :- bit.ly/3tiAlHo
Node JS :- bit.ly/3GT4liq
Rest Api :-bit.ly/3MjhZwt
Servlet :- bit.ly/3Q7eA7k
Spring Framework :- bit.ly/3xi7buh
Design Patterns in Java :- bit.ly/3MocXiq
Docker :- bit.ly/3xjWzLA
Blockchain Tutorial :- bit.ly/3NSbOkc
Corda Tutorial:- bit.ly/3thbUKa
Hyperledger Fabric :- bit.ly/38RZCRB
NoSQL Tutorial :- bit.ly/3aJpRuc
Mysql Tutorial :- bit.ly/3thpr4L
Data Structures using Java :- bit.ly/3MuJa7S
Git Tutorial :- bit.ly/3NXyCPu
Donation:
PayPal Id : navinreddy20
www.telusko.com
I started with Navin 3 years ago. I've watched lots of others since aswell but he remains the best.
sir u r perfect always do crisp video upto point. Thank u so much for such amazing playlist.
Also there are new features for interfaces in new JDK version, where we can use default method and static method with implementations inside a interface class. FYI
I have an idea for that, we just change type data, for example, we declare that A obj = new B(), and we could you some methods that belong to the A class. But we want to use the run function that belongs to the B class, simply using this command ((B) obj).run(). It will work well.
Yes it worked, but don't you think it is written purposely . Like behind it we have a reason?
This is call method casting for obj reference. Am i correct?
is this a one-time use(liek after that command the reference is still A)? or does is change the reference of the obj from A to B?
great explanation. thank you so much 🤩🤩
You're saving my life! Thank you!
I also observed you can extend a normal class and implement an interface within one class
you're saving my money
You missed why we use the default private and static method in interface after Java 8 ?
Better to create class B object with reference B so that we can access all methods of interfaces and class B
I asked myself the question and tried it out since I was not sure what would happen.
All of a sudden I love interfaces lol. You can restrict by making the object of either type 1 or 2 (interface 1 or 2) or you can make it access all interfaces by instantiating an object with the type of the implementing class so it gets access to both interfaces since the class implements both.
even works if the interfaces methods have the same name, since they have no body you have to implement the method body once yourself.
cool stuff!
@@TuxTuxedo-oc9kgomg I just realized by reading your comment that I can access the methods in both interface A and X by creating an object of class B with class B as the reference. different approach than what sir navin did in this video.
(Next Video) Need of Interface in Java -> czcams.com/video/AG_7wWFBquQ/video.htmlsi=Pb8fNRY3lLjxzrL7
Sir even class b also should become abstract because the methods we using are abstract in interface class
The B class should be abstract when we not define all abstract methods in it and later we can define remaining methods in sub class of B.
Then finally the subclass of B should be non abstract class.
Sry mapla I'll not interested😜