Java Tutorial # 18 | Abstract classes and Methods in Java -Java Beginners tutorial by Java9s


Video is ready, Click Here to View ×

This video tutorial explains about the Abstract classes and Methods. Abstract Methods does not have implementation and Abstract classes cannot be instantiated. I have explained about the importance of Abstract classes and how sub classes should override the Abstract classes methods.

24 thoughts on “Java Tutorial # 18 | Abstract classes and Methods in Java -Java Beginners tutorial by Java9s

  1. 1.there is no return type defined for storeContact() method in mobile. cannot override method marked as final in subclasses ie. calculator()
    3.storeContact() method is not overridden in SmartPhone class.
    4.there is no implementation given for chat() method in SamsungGalaxy class, it has to be abstract.

  2. 1) Void Calculator method in smartphone class cant be overrided from its superclass method , as void calculator is a final method in the mobile class.
    2) The samsung galaxy class has to be a abstract class as it has a void chat(); abstract method in it or provide some implementation to void chat() method and make it concrete method.
    3) The abstract method storecontact () is not implemented in any of the subclass.

  3. 1) Cannot override the final method from Mobile
    2)The type SamsungGalaxy must implement the inherited abstract method Mobile.storeContact()
    3)chat method requires a body instead of a semicolon

  4. 1. The SamsungGalaxy class contains an abstract method, and thus the class itself should be abstract as well (so that the subclass can fulfill the contract of implementing the chat() method).

    2. The abstract method storeContact() is never implemented in any of the subclasses. This is illegal.

    3. There is no return type for the abstract method storeContact(). This is syntactically illegal.

    4. The calculator() method is not an abstract method, and thus an implementation (which in this case, does nothing) is provided. However, it has the final keyword set, yet the SmartPhone subclass that extends the abstract class containing the calculator() method provides an implementation for the calculator() method. This is illegal because a method declared final cannot be overridden.

  5. For the Brain Teaser.
    1)The video chat method is not given any implementations in the SamsungGalaxy class.
    2) The abstract method storeContact is not being overriden.
    3) The Method Calculator which is marked as final is being overriden.

  6. First thing is that you can't override a method which marked as final so method calculator can't be override in the SmartPhone class.Second thing is that there is a implementation of call method in SmartPhone class but no implementation for storeContact method it must be override in SmartPhone class.

  7. awesome…Sir I have a question. How does java know the arbitrary abstract method names? Suppose that  I use an arbitrary method name "gosterLan()"  instead of draw() or render  etc.. any ideas?

  8. Abstract class (Smartphone) that is extending Mobile class can't implement any methods ( i.e. calculator and call) as it's been declared as abstract. I'm not sure about SamsungGalaxy class as there is no class as Smartphone though its syntax is right. StoreContact needs a return type. Kindly correct if I'm wrong. 

  9. Great Lecture. Its clear and precise. My personal feeling is that it could be even more better if you can use some IDE like eclipse to demonstrate the code part, as it checks for errors while coding.
    Thank you!

  10. 1. The StoreContact method belongs in the Mobile abstract class should have a return type.
    2. The Smartphone class can not override the implementation of the final void calculator method of the Mobile class 
    3. The concrete class SamsungGalaxy is miss the implimentation of the abstract method StoreContact belongs in the Mobile class.
    4. The concrete class SamsungGalaxy is miss the implimentation of the method public void chat(), belongs in its own Class.
    So SamsungGalaxy class should be declare as abstract or it should implements all the abstract methods of its super class. 

  11. Sir dis is satyamanyu,may u tell me what's d basic difference between interface & abstract class,i mean some authors say tat interface can not contains any concrete method,it only contains abstract method ,but abstract class may contain,is dis true,may u tell me wat's d basic difference between abstract classes & interface?

Leave a Reply

Your email address will not be published. Required fields are marked *