Difference between Abstract Class & Interface?
Answer Posted / adikeanand@gmail.com
ABSTRACT CLASS:
1)abstract class contains abstract methods with body and concrete methods also.
2) when a class contains abstract methods declare the class as abstract.
3) when we don't want to allow anybody to create object to the class then declare class as abstract.when we want to use the methods of a abstract class write a class which extends abstract class and create reference variable to abstract class and assign subclass object.
4)We can not create object to the abstract class but we can create reference variable.
INTERFACE:
1)Interface contains abstract methods and static final data.
2)when we are writing a class which implementing interface then we have to provide the body for all the abstract methods of interface.
3)If we don't want to provide all the methods of interface then declare the class as abstract.write the class which extends abstract class and write the methods which you have left abstract methods and create reference variable to interface and assign the object of class which extends abstract class.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is stateless and stateful in java?
Does jvm maintain a cache by itself? Does the jvm allocate objects in heap? Is this the os heap or the heap maintained by the jvm? Why
Explain the reason for each keyword of public static void main(string args[])?
Why are command line arguments passed as a string?
What is data encapsulation?
How do you run an executable jar file?
What is lambda used for?
What's the difference between code-based security and role-based security? Which one is better? : java security
What is the difference between a while statement and a do statement?
Can we use lambda without functional interface?
In which language eclipse is developed?
What is java net url?
What is the difference between java se and java ee?
program A and B are analysed and found to have worst case running time greater than 150NlogN and N*N respectively. which program has the better guarantee after the running time for the large values of N(N>10000)? which program has the better guarantee for the running time of small program N (N<100)? which program will run faster on average for N=1000?
What are the Advantages of java se 8 new features?