a little bit of confusion on abstract class in java.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    a little bit of confusion on abstract class in java.

    i knew that the abstract class must have at least one abstract method.

    but today accidentally my conception proved as wrong.
    that without having any abstract method the class can be abstract.

    why it is valid.....is there any logic?????


    plz explain me ....
    kind regards.
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by dmjpro
    i knew that the abstract class must have at least one abstract method.

    but today accidentally my conception proved as wrong.
    that without having any abstract method the class can be abstract.

    why it is valid.....is there any logic?????


    plz explain me ....
    kind regards.
    Abstract classes don't need to have any abstract methods at all. Simply marking
    the class as abstract is enough. The class can not be instantiated then, i.e. it
    needs to be sub-classed (extended) by a concrete (not abstract) class.
    Note that abstract classes can not be marked final too, i.e at most one of those
    classifiers is allowed: either concrete (and possibly final) or abstract.

    kind regards,

    Jos

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by dmjpro
      i knew that the abstract class must have at least one abstract method.

      but today accidentally my conception proved as wrong.
      that without having any abstract method the class can be abstract.

      why it is valid.....is there any logic?????


      plz explain me ....
      kind regards.
      You could read the free java classes on this site.

      Comment

      • rsrinivasan
        New Member
        • Mar 2007
        • 221

        #4
        Hi,
        An abstrack class may or may not have abstract methods. It is depends on the purpose of the class(abstract) . if u declaring abstract keyword before the class, it is constdered as abstract class.

        Thaks,
        Srinivasan r.

        Comment

        Working...