This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Q on abstract classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Q on abstract classes" Watch "Q on abstract classes" New topic

Q on abstract classes

Kedar Dravid
Ranch Hand

Joined: May 28, 2004
Posts: 333
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.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
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.

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Don't get me started about those stupid light bulbs.
subject: Q on abstract classes
Similar Threads
Compiler vs. Runtime Errors
Use of constructor in abstract class?
Abstract, Interfaces!
Abstract vs. Interfaces
abstract methods