When to use Interface and when Abstract class in real applications
Вставка
- Опубліковано 3 жов 2024
- 1. Full .NET Interview Course (with PDF Book)
C# / ASP.NET Core / MVC / API - Top 500 Interview Questions
www.udemy.com/...
Don't worry if course not helping you, Udemy has 30 days Free Refund Policy.
2. Quick Revision Book (PDF format)
Top 500 .NET Interview Questions - OOPS/ C#/ ASP.Net/ MVC/ SQL /.Net Core /Web API
imojo.in/inter...
50% Discount Applied on above link.
Don't worry if book not helping you, I will return 100% of your money with in 7 days of purchase. Just mail me at anuragrawat123@gmail.com.
My best wishes are with you.
Ek simple analogy :
Imagine you have 10 variants of 🍔 ,
Each variant has different magic masala for flavour change so this "Masala" is your interface, it's present in all 🍔 but different "Masala" are used
Each 🍔 will definitely have same "tikki" this is your abstract i.e. it would be same through all variants of 🍔
Wow great simple explanation with exact point in 30 second ❤️
Glad you think so!@anurag
We can define concrete and static methods in an interface also. The main difference between an interface and an abstract class is that in an interface, we can't declare instance variables only constants, which are implicitly public, static, and final. This means all implementing classes must share the same value for these variables. But an abstract class can have instance variables, allowing each subclass to have its own values for these variables.
Abstract class treats as interface but only for their own derived class not for others
Tq for your knowledge sharing and this shorts approach is really nice 🤗 once again Tq
Thanks Sai
Thank you. Good explanation.
Very important Questions for Interview
Tq for simpley explain
Happy you liked it @ Santosh
Thanks for sharing this content because it is the need. Specially for programmers to know these things in a shorts Videos. Because shorts do not bore the Viewer.
Glad it was helpful! @waqasawan4999
We can also use Static methods in interface since it is considered to be common across all the implemented classes.
No Rajdeep, we cannot use Static methods in interface. You can check.
@@interviewhappyWe can. You kindly be aware of these before teaching others.
@@interviewhappybut in java 8 we can also use staticethods
Sir plz explain difference between abstract class and interface
I am sorry if I'm wrong...but If you want method in a base class to be implemented in the same way in all derived classes, using an abstract class is not the typical approach. In an abstract class, non-abstract methods can be optionally overridden in derived classes, so they won't enforce a uniform implementation... kindly help me with this
don't use the virtual keyword thus you can stop overriding.
Abstract class treats as interface but only for their own derived class not for others. But Interface can be implements for other
What about interfaces with default methods? Also what about the subclasses overriding parents' methods?
The clear and simple difference between an abstract class and an interface is STATE!
abstract classes are meant to manage state whereas interfaces don't
Great, you described it in the best possible way
What is meant by State
but now you can implement body to the methods from an Interface, so it get a little bit hard to choose
Then go with abstract class to maintain the difference
I love C#!
@interviewhappy please do some more questions like short videos it will help to all , they will not get boor.
Sure, I will try to do more. All the best for your career.
@@interviewhappy thank you brother 🤝
@@interviewhappy please can you give application based examples for all d oops concepts
how can anyone declare abstract class with public keyword
Hi sir, I need full video link.kindly pls share
I thought it's java until I saw "Console. ..."
Abstract class treats as interface but only for their own derived class not for others. But Interface can be implements for others.
Awesome ❤
Thanks 🤗 Harikrishnan
Can we override the defined method in abstract class in derived class? If yes, then "blue" can be changed to "Red" in derived class.right?
yes, you can
interface will note have access modifier sir 😅😅 your interface example is wrong
Interface members are implicitly 'Public'. Nothing wrong mentioning Public as access modifier
please make full video in Hindi
bilkul.. I have my hindi channel also.
Bro your concepts are not clear we can have static and default methods slso in interface
Wow😍😍
Thanks
Confused
WEN R U GONA LERN EENGLISH
ven??? English please!
Your accent is strong and it is hard to understand
Yeah, it's Indian accent. Sorry, but it's natural. Can't help.
There’s also a closed caption on the video that you can read.