| This article is ratedStart-class on Wikipedia'scontent assessment scale. It is of interest to the followingWikiProjects: | |||||||||||
| |||||||||||
Is it possible for an Interface to implement other interface or extend an abstract class?
This article is barely readable. Here is a quote from it:"Interfaces are used to collect like similarities which classes of various types share, but do not necessarily constitute a class relationship."
I believe that if you take the world "like" out of the sentence, you can understand it better.
but can any interfaces(e.g Connection) have defined methods(e.g createStatement)?
An interface will not have any body(definition) in it's method. It's methods are made to be override. Think of an interface as a contract. Every method in that contact must be used in your class. You must implement all methods from an interface in the class that will use it. In that class you will override the interfaces methods and give them their body .
here is a sample interface
public interface DriveCar {
// constant declarations, if any
//notice the methods have no bodies int switchLane(double mph, double mphFinal); int Turn(boolean turnSignal);
}
There are identical interfaces inC#.exe15:31, 27 August 2007 (UTC)[reply]
Hi, I have re-worded parts of this, hope everyone approves of the new version. It needs an example of interfaces with embedded classes and interfaces. Can anyone think of examples to fit the existing ones?Mike0001 (talk)12:20, 22 February 2008 (UTC)[reply]
The example in the Examples section doesn't demonstrate the usefulness of an interface... now it's a pretty awkward construction to let a monster roar, but that shows nothing.. it doesn't show that an interface can be used to implement a level of abstraction in an application. -Simeon (talk)11:17, 1 July 2008 (UTC)[reply]
As someone who is trying to figure out what an 'interface,' (the Java kind,) is, the first sentence of this article was extremely frustrating, because it uses the word 'interface' a million times. I know that it explicitly differentiates 'generic' interfaces from the actually programming construct, but it would be nice if the article used different english words to refer to the different concepts, instead of awkwardly using the same word over and over. And another thing, when it links me to what an 'interface,' is (the Computer Science kind,) I don't think that article describes the desired kind of interface: We're not talking about GUIs (user interfaces) nor interfaces to hardware.
—Precedingunsigned comment added by128.233.135.237 (talk)21:26, 23 July 2010 (UTC)[reply]
Would it be appropriate to include information about how a generic class uses the "extends" keyword when inheriting from a base class AND multiple interfaces? For a refernce of what I am speaking of, view:http://stackoverflow.com/questions/4258447/what-does-the-java-compiler-do-with-multiple-generic-bounds .64.55.132.4 (talk)18:49, 2 July 2012 (UTC)[reply]
Am I right that a concrete class cannot add any new public methods if it is only implementing interfaces and does not have an "extends" relationship with a superclass? It seems to compile but will not expose the method to calling classes. --Beland (talk)19:01, 24 July 2013 (UTC)[reply]
Java 8 is redefining interfaces by allowing them to implement concrete methods:http://www.javabeat.net/virtual-extension-methods-in-java-8/
I think it should be added to this page in a special java 8 section, here's the official oracle link:http://www.oracle.com/technetwork/articles/java/lambda-1984522.html— Precedingunsigned comment added by117.194.255.24 (talk)18:33, 30 January 2014 (UTC)[reply]
I've had an idea regarding the proposed merge into theProtocol (object-oriented programming) article, andI've already mentioned it on the relevant threads regarding that proposal, but I figured I should mention it on the talk page for this article as well, seeing as that plan involves this article as well.
In short, reworking this article to be about Interface types in general, rather than specifically about Java'sinterfaces. Along the same lines asEnumerated type,Function type,Abstract type, etc. After all, Java's interfaces by themselves probably aren't notable enough for an article of their own (as perWP:NOPAGE), but, reworking this article to be primarily about interface types/language equivalents (with small sections specifically on Java/C#/TypeScript/Golang'sinterfaces, Python'sProtocol, Rust'straits, etc) would probably be more appropriate.
I'm going to refrain from making any major changes pending the outcome of the merge/move discussions over onTalk:Protocol (object-oriented programming), but I figured I should at least mention it here in advance, whilst I'm thinking about it.🔥HOTm̵̟͆e̷̜̓s̵̼̊s̸̜̃🔥 (talk・edits)13:27, 14 November 2022 (UTC)[reply]