what is difference between interface and abstract class..?
Answer Posted / nipun advinder
Interface:
1)In interface you cannot provide any implementations of
any function.
2)you must give implementations for all the methods of an
interface if you implement it in a class
3)cannot have private method
4)Scenario to use it would be to separate out the
implementation from the api
Abstract Class:
1)In interface you can provide implementations of any
function but at least one function should be abstract.
2)you must give implementations for all the abstract
methods of a abstract class if you extend it in a class
3)can have private method
4)Scenario to use it would be to denote is as a generalized
class which could provide some common functionality and you
want that it cannot be instantiated instead more
specialized forms are used.
eg abstract class account
class savingsaccount extends account
class currentaccount extends account
In this scenario assume that class account cannot provide
the complete functionality alone but contain some standard
ones.
| Is This Answer Correct ? | 3 Yes | 1 No |
Post New Answer View All Answers
What checkbox method allows you to tell if a checkbox is checked?
What do you understand by the term string pool?
What is immutable state?
What is variable length arguments in java?
Is arraylist ordered?
Explain creating threads by implementing runnable class?
what is the difference between Object Based Language and Object Oriented Language?
Explain the difference between extends thread vs implements runnable in java?
What is set string?
What is lazy programming?
What does it mean that a method or field is “static”?
Explain the inheritance?
Is age a discrete variable?
Difference difference paint() and paintcomponent()?
What is boolean logic?