Forums Register Login

Java Basic

+Pie Number of slices to send: Send


How to explain interface of an object?
+Pie Number of slices to send: Send
Its rather interface of a class .
Refer below
Interfaces
+Pie Number of slices to send: Send
Please don't use thread titles like "Java Basic"
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
@Campbell Ritchie
sorry and i shall take care from now on.
Thanks for suggestion.
+Pie Number of slices to send: Send
An interface is a type of contract: a class that implements an interface must, at minimum, include implementations of the interface.
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
...
+Pie Number of slices to send: Send

Ok i got the point, Thank you Vishal Hegde, Pratik D mehta, David Newton, and Hebert Coelho for your valuable replies.
+Pie Number of slices to send: Send
Interface of the object is the method/methods through which it interacts with other objects or other part of program.
+Pie Number of slices to send: Send
 

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?
+Pie Number of slices to send: Send
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.)
+Pie Number of slices to send: Send
 

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
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 986 times.
Similar Threads
Difference between serializing an object and saving its state in the Database
JSF custom validation message
Integer Pool
* Welcome Frits-Johan Walraven
How can we compare JavaFX with Flex4 ?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 01:42:11.