• Post Reply Bookmark Topic Watch Topic
  • New Topic

Not able to understand the below sentence please assistBy putting nonabstract methods in an abstract  RSS feed

 
Vishal Hegde
Ranch Hand
Posts: 1078
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

By putting nonabstract methods in an abstract class, you give all concrete subclasses (concrete just means not abstract) inherited method implementations. The good news there is that concrete subclasses get to inherit functionality, and need to implement only the methods that define subclass specific behavior
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use quote tags for that sort of text, not code. I have changed it and corrected a spelling error.

Which part of that do you find hard to understand? You know there is no need for an abstract class to have any abstract methods at all. Any non‑abstract methods will appear in subclasses, too. So you don't have to override them if you don't want to. The fewer abstract methods there are, the less work you have to do to implement the subclasses.
 
Paul Clapham
Sheriff
Posts: 22841
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Consider this slightly revised quote:

By putting methods in a class, you give all subclasses inherited method implementations. The good news there is that subclasses get to inherit functionality.


I think you would agree that is true. And the original quote simply reiterates that information for the case of abstract classes. Don't get the idea that abstract classes are some totally different kind of thing; first of all an abstract class is a class.
 
Arun Giridhar
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
good example of that would be HttpServlet .
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!