Bloomberg LP Interview Question
Software Engineer / DevelopersTeam: Supply Chain
Country: United States
Interview Type: In-Person
Abstract classes can have constants, member, method and defined methods whereas interfaces can only have constant and methods.
You can defined any method in abstract class with different specifier but in interface must be defined as public.
When you inheritance any abstract class than you have to define the all abstract methods
and interface can extend or a class can implement multiple other interface.
A class is said to be abstract when it has one or more methods as abstract.
Abstract class is a class where as interface is not. We can define methods in abstract class whereas we can't in interface.
We use abstract classes instead of interface when we need different access type methods as interface can only have public.
Also if there are any updates(new methods) to an interface all the classes implementing it have to be updated and are required to implement it. Whereas in case of abstract a new method inside the abstract class is the only thing required without any change to the rest of the code.
Abstract class may contain abstract as well as concrete methods but interface only contains abstract methods.This indicates that abstract class may provide partial implementation but interface don't.so using interface we can achieve 100% abstraction whereas using abstract class we can achieve partial abstraction.
- Anonymous December 12, 2014