Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where did java get the idea for Interfaces from?

Tags:

java

I'm aware that most things in modern programming languages are at least partially based on features in earlier languages.

This leads me to wonder where java got the inspiration for interfaces from. Was it mostly their own creation? Was it based on fully Abstract Base classes(with multiple inheritance) ?

like image 849
Roman A. Taycher Avatar asked Oct 03 '10 02:10

Roman A. Taycher


People also ask

Why did the concept of interface emerge in Java?

Why do we use an Interface? It is used to achieve total abstraction. Since java does not support multiple inheritances in the case of class, by using an interface it can achieve multiple inheritances. It is also used to achieve loose coupling.

Who invented interfaces?

Douglas Engelbart, (born January 30, 1925, Portland, Oregon, U.S.—died July 2, 2013, Atherton, California), American inventor whose work beginning in the 1950s led to his patent for the computer mouse, the development of the basic graphical user interface (GUI), and groupware.

What is the concept of interface in Java?

An interface is a reference type in Java. It is similar to class. It is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface. Along with abstract methods, an interface may also contain constants, default methods, static methods, and nested types.

Where are interfaces defined in Java?

Interfaces are declared using the interface keyword, and may only contain method signature and constant declarations (variable declarations that are declared to be both static and final ). All methods of an Interface do not contain implementation (method bodies) as of all versions below Java 8.


1 Answers

In a recent Objective-C book I was reading Learn Objective-C on the Mac, the authors suggest that the primary inspiration for Java's interfaces are from Objective-C's implementation of Formal Protocols.

Formal Protocols in Obj-C are files, just like Java's Interfaces, that are filled with abstract methods – or plainly just the method headers – that the developer must implement if the Formal Protocol is used. In the most recent update to Apple's Cocoa, Formal Protocols can also include optional methods which the developer doesn't need to implement if the class implements the protocol.

like image 140
Sean Avatar answered Nov 01 '22 03:11

Sean