Which two reasons should you use interfaces instead of …

Which two reasons should you use interfaces instead of abstract classes?

Which two reasons should you use interfaces instead of abstract classes?

A.
You expect that classes that implement your interfaces have many common methods or fields, or require
access modifiers other than public.

B.
You expect that unrelated classes would implement your interfaces.

C.
You want to share code among several closely related classes.

D.
You want to declare non-static on non-final fields.

E.
You want to take advantage of multiple inheritance of type.

Explanation:
http://www.programmerinterview.com/index.php/java-questions/interface-vs-abstract-class/



Leave a Reply 5

Your email address will not be published. Required fields are marked *


smh

smh

B. You expect that unrelated classes would implement your interfaces.
E. You want to take advantage of multiple inheritance of type.

Berti John

Berti John

B,E. is correct

smh

smh

why not C. interface is best choice for closely related classes to share code from interface.