Q&A Categories
Find a Question:
Java Interview Questions and Answers
What are the drawbacks of inheritance?
Answer this Question
You must be Logged In to post an Answer.
Not a member yet? Sign Up Now »
Hot Interview Questions of Java
- » What is weak reference in Java.
- » In which case would you choose a static inner class?
- » What are the different types of inner classes?
- » Can you call one constructor from another if a class has multiple constructors?
- » How to check two arrays to see if contents have the same types and contain the same elements?
Star Points Scale
Earn points for Posting and Commenting Papers!
[1 - 25
[26 - 50
[51 - 500
[501 - 5000
[5001 - 25000
[25001+
Answer #1
Since inheritance inherits everything from the super class and interface, it may make the subclass too clustering and sometimes error-prone when dynamic overriding or dynamic overloading in some situation. In addition, the inheritance may make peers hardly understand your code if they don’t know how your super-class acts and add learning curve to the process of development.
Usually, when you want to use a functionality of a class, you may use subclass to inherit such function or use an instance of this class in your class. Which is better, depends on your specification.
Agree With Answer
0
0