Note that there are some explanatory texts on larger screens.

plurals
  1. PODifference between Reference Type and Object Type?
    text
    copied!<p>Java docs says: </p> <blockquote> <p>When you define a new interface, you are defining a new reference data type...[]</p> </blockquote> <p>Some people use the name "object type" to refer to the class used to first instantiate an object instance.</p> <p>Because we can not use an interface to instantiate an object, can I say that an object never has the type of that interface, but you can use a reference of that interface kind to access that object if it implemented that kind of interface?</p> <p>Wikipedia says: </p> <blockquote> <p>[]... a data type or simply type is a classification identifying one of various types of data, such as real-valued, integer or Boolean, that determines the possible values for that type; the operations that can be done on values of that type; the meaning of the data; and the way values of that type can be stored.</p> </blockquote> <p>I don't see how an interface in Java determines "the possible values for that type; the operations that can be done on values of that type; the meaning of the data; and the way values of that type can be stored." My reasoning is that, because interfaces don't define what the methods can do, they aren't data types and only the classes and primitive types define data types. Interfaces only define how an object of a certain data type can be used if accessed using a reference.</p> <p>Based on that, if someone say that an object that implements an interface has the same type of that interface, can I answer that he/she is wrong, because interfaces only give type for references and objects can never have the type of an interface?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload