why interfaces are faster than abstract classes?
Answers were Sorted based on User's Feedback
Answer / aruna raman
Actually abstract are faster than interfaces classes.
interfaces are Slow, requires extra indirection to find the
corresponding method in the actual class. Modern JVM's are
discovering ways to reduce this speed penalty.
Abstract Class ::
- It cannot defines all the methods
- It has subclass.
- Here, Subclass is useless
- A class can be extend an abstract class
Interface ::
- It defines all the methods
- It must have implementations by other classes, But there
will be no use of that.
- Only an interface can extend another interface.
| Is This Answer Correct ? | 16 Yes | 3 No |
Answer / laxmikant
As Interfaces always have abstract methods, it needs less
time for compiler to compile them as compared to abstract
classes which may have well defined methods for sharing
among the classes which will extend it.
| Is This Answer Correct ? | 4 Yes | 16 No |
Answer / m gangadhar
using interfaces over abstract classes is gives better
ferformance becoz interfaces does not have any constructor
but abstract classes can have. for this reason it does not
vaste time to create object.
| Is This Answer Correct ? | 11 Yes | 29 No |
Is java a compiler?
What does the string method compareto () do?
What is meant by overloading?
What is a java developer salary?
How you can force the garbage collection?
Can we catch more than one exception in a single catch block?
When will we use class loader?
suppose string s1="rajnish"; string s2="bhaskar"; then what will be happend ?
Can you override a private or static method in java?
What is use of functional interface in java 8? Explain
What is the use of list in java?
explain local datetime api in java8?