I have a class which is abstract which contains only the
abstract methods. This is similar to an interface. Then, if
i have given a choice to choose one of them. Which one i
have to choose and why?
Answers were Sorted based on User's Feedback
Answer / venu
i preferred to choose interface bcoz
if i implement interface still i have a chance to extend
another class
| Is This Answer Correct ? | 5 Yes | 0 No |
Answer / harikrishna
you never get a chance to choose a method from abstract
class,because if you are writing a abstract class you
have to provide implementation to all the methods in
subclass otherwise you should declare that subclass as
Abstractclass.
| Is This Answer Correct ? | 2 Yes | 1 No |
Answer / madhav
Interface is preferable to Abstract class as when ever in
instance is created for subclasses of this,constructors
will be called hirarchially consuming some time for each
constructor call..
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / ashoka
Better to choose Abstract class. Because it contains not
only the abstract methods but also implemented methods but
in interfaces only unimplemented methods will be there and
all final variables will be there.
| Is This Answer Correct ? | 0 Yes | 1 No |
What is the blank final variable?
What is the Set interface?
What is the difference between hashmap and hashtable? What is an interface?
What is the purpose of using break in each case of switch statement?
I want to control database connections in my program and want that only one thread should be able to make database connection at a time. How can I implement this logic?
Describe the syntax of multiple inheritance? When do we use such an inheritance?
What is callable java?
How do you implement polymorphism in our day to day life?
What is a method in java?
What does @param args mean in java?
What is the difference between exception and error in java?
What is a nested class?