Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding Abstract Class

 
Mohana Priya
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An Absract class with concrete static methods alone need not be sub-classed in its life time .Am I right ?
 
Burkhard Hassel
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you mean cannot be subclassed?
If so the answer is no, can be subclassed.

But this class needs not to be abstract, methods being static or not.
Yours,
Bu.
 
Jeronimo Sanchez
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I think Mohana is trying to ask is if all methods in an abstract class are static, do we need to sub-class the class? And the answer is no, we do not need to do so to call the static methods.

It's perfectly legal to invoke static methods within abstract classes. Check the foloowing example:



Other question is why to have an abstract class with only static methods.
 
Dave Reinhardt
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a few abstract classes with static methods in the API that are part of the SCJP exam. See page 471 in SCJP

java.util.Calendar
java.text.DateFormat
java.text.NumberFormat

Can anyone name others that we need to know for the exam?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic