why interfaces are faster than abstract classes?

Answers were Sorted based on User's Feedback



why interfaces are faster than abstract classes?..

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

why interfaces are faster than abstract classes?..

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

why interfaces are faster than abstract classes?..

Answer / kalyan g

one more thing about interface is, we dont have any
implementations,so no burden of this, hence it is good in
performance

Is This Answer Correct ?    5 Yes 21 No

why interfaces are faster than abstract classes?..

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

Post New Answer

More Core Java Interview Questions

What is an argument in java?

0 Answers  


In how many ways we can create threads in java?

0 Answers  


Define "Access specifiers" in java.

0 Answers   HCL,


How can two threads be made to communicate with each other?

3 Answers   HCL,


how many ways to create Thread and which one is good? runnable interface ot Thread class?

3 Answers   Satyam,


Which is better arraylist or vector?

0 Answers  


What is the primitive type short?

0 Answers  


Is java se open source?

0 Answers  


Which java.util classes and interfaces support event handling?

2 Answers  


What are the types of classes in java?

4 Answers   HCL,


Can we compare two strings in java?

0 Answers  


What is parsing in grammar?

0 Answers  


Categories