• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Abstract Class concept

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have some doubt in concept of abstract class. Abstarct class is one which contains altest one abstract function but there can be abstract class which dose not contain a
abstract fuction and contais only concrete methods so why it is called abstract?
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

amrut sabade wrote:i have some doubt in concept of abstract class. Abstarct class is one which contains altest one abstract function but there can be abstract class which dose not contain a
abstract fuction and contais only concrete methods so why it is called abstract?



If there's no abstract method in it- Always better to not call it Abstract. We might not want any instance of that class to be created and so we declare the class as Abstract even though there may not be any abstract method in it.

 
Ranch Hand
Posts: 479
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A class being declared abstract means that the designer of the class has judged that there should be no instance of that class, only instances of subclasses of that class. That judgement does not depend on whether there are any abstract methods in that class.

Perhaps the class must be subclassed to have any real meaning, but the relevant methods, instead of being abstract, perform no operation. This would allow there to be multiple methods, any one of which need to be implemented by the subclass in order for the object to have a reasonable meaning, but allows the implementor of the subclass to judge which one fits his particular case.

I do not agree that it is "Always better to not call it Abstract." An abstract class has a conceptual meaning; so does an abstract method, but the latter is not required in order to design one of the former.

rc
 
Did you ever grow anything in the garden of your mind? - Fred Rogers. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic