• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Basic

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


How to explain interface of an object?
 
Ranch Hand
Posts: 121
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its rather interface of a class .
Refer below
Interfaces
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please don't use thread titles like "Java Basic"
 
Ranch Hand
Posts: 1087
Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Aman,

Interface are only used for implementing classes and hence forth we write it as follows


Suppose we have class Car and interface named Model

then we can write


Interface is a contract you can say to be more precise
 
Ammy Singh
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am not asking about Interfaces in java, i am asking from general OOP point of view. A Class has an object and this object has some interface associated with it, which
tells that object what to do and how to do?
this is my point.
 
Ammy Singh
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Campbell Ritchie
sorry and i shall take care from now on.
Thanks for suggestion.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An interface is a type of contract: a class that implements an interface must, at minimum, include implementations of the interface.
 
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:An interface is a type of contract: a class that implements an interface must, at minimum, include implementations of the interface.



Just keep in mind what David said. Is a type of contract. When a concrete class implements it, it will must implement it's methods.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...
 
Ammy Singh
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ok i got the point, Thank you Vishal Hegde, Pratik D mehta, David Newton, and Hebert Coelho for your valuable replies.
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interface of the object is the method/methods through which it interacts with other objects or other part of program.
 
Ammy Singh
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Harnoor Singh wrote:Interface of the object is the method/methods through which it interacts with other objects or other part of program.



Absolutely this is what i was looking for, Thanks Harnoor Singh.

now my next question is that, is it right to say that we inherit interface of an object in inheritance and we do not inherit interface of an object in composition?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Correct: simply having a property that implements an interface doesn't mean the class now implements that same interface.

(It *can*, but in Java needs to be done manually, usually by delegating method calls to the property that implements the interface. Most IDEs can do this busy work automatically.)
 
Ammy Singh
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:Correct: simply having a property that implements an interface doesn't mean the class now implements that same interface.



:thumbup: thank you David
Regards
Aman
 
reply
    Bookmark Topic Watch Topic
  • New Topic