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.

КОМЕНТАРІ • 51

  • @devkumar9889
    @devkumar9889 7 місяців тому +19

    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 🍔

  • @AnuragRawat01
    @AnuragRawat01 Рік тому +19

    Wow great simple explanation with exact point in 30 second ❤️

  • @villagesoftwareengineer
    @villagesoftwareengineer Місяць тому +2

    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.

    • @Anuj_sk
      @Anuj_sk 2 дні тому

      Abstract class treats as interface but only for their own derived class not for others

  • @saiyandam2470
    @saiyandam2470 Рік тому +6

    Tq for your knowledge sharing and this shorts approach is really nice 🤗 once again Tq

  • @rahulmistry5381
    @rahulmistry5381 Місяць тому

    Thank you. Good explanation.

  • @santoshsatpute4425
    @santoshsatpute4425 Рік тому +1

    Very important Questions for Interview
    Tq for simpley explain

  • @waqasawan4999
    @waqasawan4999 Рік тому

    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.

  • @Rajdeep11082
    @Rajdeep11082 Рік тому +1

    We can also use Static methods in interface since it is considered to be common across all the implemented classes.

    • @interviewhappy
      @interviewhappy  Рік тому

      No Rajdeep, we cannot use Static methods in interface. You can check.

    • @fo9004
      @fo9004 Рік тому +3

      ​@@interviewhappyWe can. You kindly be aware of these before teaching others.

    • @prashanthreddy-sd9ju
      @prashanthreddy-sd9ju Місяць тому

      ​@@interviewhappybut in java 8 we can also use staticethods

  • @Thinkdifferent2003
    @Thinkdifferent2003 6 місяців тому

    Sir plz explain difference between abstract class and interface

  • @gawalipriyanka-rg5db
    @gawalipriyanka-rg5db 11 місяців тому +2

    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

    • @AhmadElkhouly
      @AhmadElkhouly 6 місяців тому

      don't use the virtual keyword thus you can stop overriding.

    • @Anuj_sk
      @Anuj_sk 2 дні тому

      Abstract class treats as interface but only for their own derived class not for others. But Interface can be implements for other

  • @yohanebergerkouokamkuisu4238
    @yohanebergerkouokamkuisu4238 Рік тому +3

    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

  • @jesusserratoaguilar7105
    @jesusserratoaguilar7105 Рік тому +1

    but now you can implement body to the methods from an Interface, so it get a little bit hard to choose

    • @interviewhappy
      @interviewhappy  Рік тому

      Then go with abstract class to maintain the difference

  • @fireloks6362
    @fireloks6362 3 місяці тому

    I love C#!

  • @ramyask3795
    @ramyask3795 Рік тому +1

    @interviewhappy please do some more questions like short videos it will help to all , they will not get boor.

    • @interviewhappy
      @interviewhappy  Рік тому

      Sure, I will try to do more. All the best for your career.

    • @ramyask3795
      @ramyask3795 Рік тому

      @@interviewhappy thank you brother 🤝

    • @Brinda-pe6ue
      @Brinda-pe6ue 11 місяців тому

      ​@@interviewhappy please can you give application based examples for all d oops concepts

  • @rakeshbhure9136
    @rakeshbhure9136 10 місяців тому

    how can anyone declare abstract class with public keyword

  • @anushashaik1118
    @anushashaik1118 Рік тому

    Hi sir, I need full video link.kindly pls share

  • @nandorboda8049
    @nandorboda8049 Місяць тому

    I thought it's java until I saw "Console. ..."

  • @Anuj_sk
    @Anuj_sk 2 дні тому

    Abstract class treats as interface but only for their own derived class not for others. But Interface can be implements for others.

  • @harikrishnanr4794
    @harikrishnanr4794 Рік тому

    Awesome ❤

  • @nagaraj221
    @nagaraj221 Рік тому

    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?

  • @preetishchindarkar9258
    @preetishchindarkar9258 Рік тому +2

    interface will note have access modifier sir 😅😅 your interface example is wrong

    • @vijayarahavan956
      @vijayarahavan956 6 місяців тому

      Interface members are implicitly 'Public'. Nothing wrong mentioning Public as access modifier

  • @vikasshankhyadhar8589
    @vikasshankhyadhar8589 Рік тому +1

    please make full video in Hindi

  • @the_rocker7786
    @the_rocker7786 7 місяців тому

    Bro your concepts are not clear we can have static and default methods slso in interface

  • @arpitsharma9325
    @arpitsharma9325 8 місяців тому

    Wow😍😍

  • @GautamMyakal
    @GautamMyakal 10 місяців тому

    Confused

  • @jordanc1860
    @jordanc1860 10 місяців тому

    WEN R U GONA LERN EENGLISH

  • @trantrungnghia9642
    @trantrungnghia9642 11 місяців тому +1

    ven??? English please!

  • @nameistverborgen
    @nameistverborgen Рік тому +1

    Your accent is strong and it is hard to understand

    • @interviewhappy
      @interviewhappy  Рік тому

      Yeah, it's Indian accent. Sorry, but it's natural. Can't help.

    • @thetruthsayer8347
      @thetruthsayer8347 Рік тому

      There’s also a closed caption on the video that you can read.