#65 Need of Interface in Java

preview_player
Показать описание
Check out our courses:

Coupon: TELUSKO10 (10% Discount)

Coupon: TELUSKO20 (20% Discount)

Udemy Courses:

For More Queries WhatsApp or Call on : +919008963671

In this lecture we will learn:
- Methods in java
- What is an interface?
- Need for an interface

#1
- We can also pass an object as a parameter in a method.
- When you build an application, you need to make it more flexible.
- We can create a reference of the parent class and an object of the sub-class.
- Passing reference and the reference of an object that you accept in a method, both should be the same.

#2
Interface:-
- Interface in Java is used to achieve abstraction.
- Interface is used to design an application to make it loosely coupled.
- implements keyword is used with a class to extend it to an interface
interface Computer
{
}
.........
class Desktop implements Computer
{
statement;
}

#3
Need of an Interface:-
- It is used to implement abstraction.
- We can also achieve multiple inheritance in Java, by using the interface.
- Any class can extend only 1 class but can any class implement an infinite number of interface.
- It is also used to achieve loose coupling.

More Learning :

Donation:
PayPal Id : navinreddy20
Рекомендации по теме
Комментарии
Автор

What an awesome tutorial!
You showed the problem and then showed how to solve it, simple and direct.
Perfect, thank you very much!

leonardorafaelli
Автор

I really do not know how to thank you! The real life example you show, and the way you show it step by step. The reason I am now good at Programming is not because of my University, it is you!

amanjain
Автор

Good explanation sir
Understood everything....

SATHWIK
Автор

Thank you so much, I've been looking for a good explanation of interfaces :)

painisgain
Автор

Simply Woow!! Its crisp and clear.. I spent 17k on Java course and ended up confused. Wish i had found you before...

SP-vqtg
Автор

what a great explanation. thank you Naveen sir

abhishekkale
Автор

When I try to keep a method which is not a public in the class which implemented from an interface, why it is showing error...

vipassassin
Автор

What about if we make a method code as abstract and use anonymous class, because the best practise to avoid instantiate classes further we need it because that make memory leak

davidhusted
Автор

u are awesome sir u teaching very fine
respect !

i_dhiraj
Автор

whats the basic difference between using interfaces and implemenths rather using abstract class with our regular inheritance extends keyowrd?

can anyone plz explain me?

MohdKhan
Автор

Bhai, you are the best teacher who teaches with the best and simplest examples.

sher.
Автор

One question when we need to go for Abstract vs Interface

sridharmurari
Автор

Hi, I'm confused. It seemed like your video showed the value of an abstract class Computer. But, then, in the last 10 seconds of this video, you changed Computer from an abstract class to an Interface. But, I'm not sure what the value is for changing it to be an interface? It seems like the real value was gained by having Computer be an abstract class.

andrewjenson_original
Автор

Your teaching is well. but here I have a question. You have showed loose coupling using inheritance, abstraction and interface. All are working well. But when can we choose the suitable one?

HabiburRahman-dmyt
Автор

I tried this and it works fine but there is a flaw. if the variable type is Computer then I cannot use the property and method of the children class as the compiler at the moment we compile the code only know the members of the Computer class. But it works if we just want to reuse the code function with different implementations. Great video by the way sir

ctyfwdg
Автор

When we create a reference to the parent and object of child we can only access the methods of the parent but how did you code was able to acccess the methods of the child

ALENBELJI
Автор

Congratulations boys and girls for more than 60%completion !!!! Just a few more to goooo!! Les ghoooo💪

sastisfya
Автор

hy, sir in the #65 video you should modify your example as the comapny can give a developer a laptop or desktop rather than a devolper need a laptop due the wrong example i have to see the videoo again to understand the concept

ALIHAMZAAKRAM-oesu
Автор

you just showed what an interface can do with abstract class. what is the difference? why we need interface

kamakshijayaraman
Автор

What is the main difference between abstract and interaface? Besides the fact that interface is not a class, how to know when to use which ?

majorgab