Citrix System Inc Interview Question
Software Engineer / DevelopersTeam: Shared file
Country: United States
Interview Type: Phone Interview
Interface defines what requests you can send to the object.Interface defines how it can interact with the outside world.Interface is like I/o for the class.On the other hand Inheritance defines what attributes are handed over to the class in general.Multiple inheritance is not allowed due to duplication of interfaces.
Interfaces has set of abstract methods which should be implemented by the Classes which implementing them . it can have static member variables. it is the abstraction of what to do. When classes implement the interfaces , all of the methods in interface should be implemented.
- vetriblogger1187 April 10, 2014interfaces do not have any implementaion . Inheritance is the property of deriving the superclass. Inheritance helps to override the specific method of superclass and classes can have all the functionalities by inherting the superclass.
Multiple inheritance is not allowed because of Diamond Problem.
Lets say Class A has method foo and it s inherited by Class B and Class C. both Class B and Class C override the foo method. now Class D extends ClassB and Class C overriding foo method. if we refer just foo compiler wll not able to decide which foo to invoke.
Multiple inheritance does complicate the design problem. java allows single inheritance with mulitple interfaces to clear this ambiguity