TOP 6 difference between Abstract class and Interface in JAVA || Must know facts

preview_player
Показать описание
This tutorial covers the difference between abstract class and interface.As we go further with this tutorial we are going to learn the top 6 difference when we compare interface vs abstract class in java.

First Lets talk about what is interface in java and what is the use of interface in java ?

So when we know the specification but not aware of the implementation, then we should go for an interface.

Then the next question will be what is abstract class in java and what is the use of abstract class in java ?

The answer is very simple, When we know the partial implementation then we should prefer abstract class.

I will try to demonstrate you the difference between interface and abstract class with a simple example with this tutorial.

——————

The abstract keyword is used to create an abstract class whereas interface keyword is used to create an interface.

------------------

The variable of an abstract class can have final, non-final, static and non-static variables whereas the variable of an interface should be always public static final.

————————

Another difference between abstract class and interface in java is :
we can achieve multiple inheritances by using interface whereas with an abstract class it is not possible as multiple inheritance is not supported by java.

——————————

[

Why we need constructor inside an abstract class ? || Popular Java interview question

———————————

An interface in java can have an only abstract method within it whereas the abstract class in java can have both abstract and concrete method within it.
(FYI: from java 8 we can have both concert and abstract method within an interface )

To know more, watch this tutorial :

INTERFACE IN JAVA 8 with REAL TIME code ||Why DEFAULT Method?[Explained]

——————————————

Well, we can have few more differences as well but these are the few common difference between abstract class and interface in java that each developer should
aware of.

-------

Please subscribe to my channel by clicking on the link below.

Stay tuned and like my Facebook page for more.

Music :
-----------
credits : -

Creative Commons — Attribution 3.0 Unported— CC BY 3.0

-----

intro template :
Рекомендации по теме
Комментарии
Автор

Nice bro. thumbs up (go to 5:55 and make some correction you made both abstract method.)

mdmojahidshaba
Автор

This is how it should be explained! Every segment is explained and covered with an example, well done. No time wasted here.

crazyrider
Автор

Finally someone who knows how to explain things, well done!

inesbrenner
Автор

Finally came to know the clear the difference between Abstract and Interface. Thanks bro.

manikannanmarimuthu
Автор

Best video about the interface and abstract class. so glad to watch it.

xerinaysawutaji
Автор

Good explanation !! Also one important reason why abstract class has constructor is to achieve constructor chaining. As we know the sole purpose of abstract class is to be extended. Now in any sub-class when object is created and initilized the first call under its constructor is call to super () i.e call to super class constructor and so abstract class has constructor. So if you don't keep any constructor explicitly then jvm keep one default constructor to abstract like other normal class. A constructor chaining goes till Object Class.

pallavrajput
Автор

Wow this is the best explanation for interface and abstract class. Thank you so much.

AmeyChittar
Автор

Ur concepts are crystal clear This is the best video abt abstract classes and interafaces. Keep it Up God bless you and ur family

zameerahmed
Автор

Maqsood bhai tum boht acche se samjha ta hai !! thank u

akshatjain
Автор

Best Instructor at Best time . Currently I am trying to switch company your videos conatins most of those questions with best answers(Indian Version). Feels like entire Java interview questions at one place .
Thanks is a small thing :D

jaganmohanmylapuru
Автор

Well done . Thank you for the clear explanation.

NourKhafaji
Автор

Fantastic explain thank you You are Spark 🔥

varunrickstudios
Автор

Good one. (at 16:50 the constructor and class name mismatching.)

sainathpabba
Автор

Thanks very much for this video. No offense, but when I saw that you were Indian, I almost didn't watch. I have a problem with accents at my age, you see.

Anyway, because your accent wasn't that thick, I struggled through, and I'm glad I did. Yours is probably the best video on YouTube for explaining interfaces and Abstract classes. Everybody else just parrots what they've heard in other videos.

Thanks again, I plan to watch more.

prima
Автор

In Java 8 : Functional interface is an interface that contains only one abstract method.

vijaymohan.p
Автор

I like this channel very much Abhilash will teach very easiest way !!!!Thank you😇😇😇

vakkalahari
Автор

Why dislike to this video..disliker please give explanation?? Your videos are very helpful dude👌👌

shashanksinghsisodiya
Автор

Seriously this is top class i literally lost 3 interviews because of this question but this time i confident to answer

ramanavanchanagiri
Автор

This is how it should be explained. Crisp and yet detailed. Thanks for making this man 👍🏽👌🏽

ankush
Автор

thanks...you are so cool.very clear explanation

АльфредГордан