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
How many types of memory areas are allocated by jvm?
Explain the reason behind ending a program with a system.exit(0)?
What is the effect of keeping a constructor private?
how to know the total memory occupied by the objects in the ArrayList(Array list may contain duplicate objects)
Explain about transient variables in java?
Print Vertical traversal of a Binary Tree.
what is meant wrapper classes?
What are actual parameters?
What do you understand by java?
What is method overloading in java ?
How to handle a web browser resize operation?
How do you convert an int to a double in java?
Why is static used?
What does java final mean?
What are the two types of java?