• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Q on abstract classes

 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Recently, at an interview, I was asked the following question:
"Of what use would be an abstract class which has only one non-abstract method?"

I couldn't quite figure out the answer to this one. Any pointers in this direction would be welcome.
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's my guess: Suppose the class in question was a class named A.
Suppose A extended another abstract class S, or implemented an interface I, but A did not provide an implementation for any methods in the superclass S or interface I, then the class A must be declared abstract. The fact that it provides a single non-abstract method is irrelevant, I think. On the other hand, a class A with no behaviour (methods) at all would be rather pointless.
 
reply
    Bookmark Topic Watch Topic
  • New Topic