Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Object interface theory question  RSS feed

 
Chris Yates
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it correct to say that an object interface is the methods that the object has to communicate with the outside world? Or it's something more than this?
How you would you briefly define what it is?
 
Tim Cooke
Marshal
Posts: 3858
233
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The definitive answer: The Java Tutorials: What Is an Interface?
 
Knute Snortum
Sheriff
Posts: 4073
112
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it correct to say that an object interface is the methods that the object has to communicate with the outside world?

I would call this the class's API. Note that an object is created by a class, or more accurately, an object is an instance of a class.
 
Chris Yates
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So API is not same as interface :| API is all the methods an object has to comunicate with other objects. What is the interface?
 
Campbell Ritchie
Marshal
Posts: 55678
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that there are two different meanings to the word interface. There is the commoner meaning which means place or area where two things meet, and the specific meaning of the Java® interface keyword to mean a structure specifying behaviour but without an implementation. That latter changed in Java8.
I would say that the public interface of a class comprises its public methods and public fields and probably its public constructors. Of course, you will not normally have any public fields. Remember what the I in API means.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!