• 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
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

abstract classes

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
Can an abstract class have -- no abstract method. What I mean is, if we declare an abstract class is it legal to have no method which is abstrtact.
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes..its perfectly valid to have an abstract class without any abstract methods.
You can also bootstrap the JVM using main method in the abstract class.
However u can't instantiate an object of the class since its abstract.
 
Ranch Hand
Posts: 522
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Mona,
An abstract class is not a complete class, that is why you can't instantiate it, they exist only to be extended. The answer to your question is yes, as Rajeshwari suggested.
But be carefully, if there is at least one abstract method in your class then you MUST declare that class abstract.
Hope this helps.
 
Mona Gadkari
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello,
Thanks Vicken and Rajeshwari.
 
reply
    Bookmark Topic Watch Topic
  • New Topic