Rakesh Kadulkar
Rakesh Kadulkar
If an interface has no direct superinterfaces, then the interface implicitly declares a public abstract member method m with signature s, return type "r", and throws clause t corresponding to each public instance method m with signature s, return type "r", and throws clause t declared in Object, unless a method with the same signature, same return type, and a compatible throws clause is explicitly declared by the interface. It is a compile-time error if the interface explicitly declares such a method m in the case where m is declared to be final in Object.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
You can do that for yourself in the API documentation.Mina Daoud wrote:Can you check what is the class Object and its purpose?
Campbell Ritchie wrote:
You can do that for yourself in the API documentation.Mina Daoud wrote:Can you check what is the class Object and its purpose?
Rakesh Kadulkar
Sorry. I misunderstood that.Mina Daoud wrote: . . . It wasn't reply to your post . . .
rakesh kadulkar wrote:To all,
I know that the hashCode() method is coming from the Object class because while programming in java Object calss is inevitable.
My question was
"If I have a reference of type interface which does not have a hashCode() method in it then how come I can call hashCode() method on the target object using that interface reference"
With some of the reply I understood that if it is a top level interface then it has by default hashCode() method in it.
Otherwise there is no magic happening here.
The javap command only shows code declared in the current class. It doesn't show anything inherited unchanged from Object.Mohit Singhi wrote:. . . after compilation as you can see their is no hashCode() method in interface A when you run javap A command. . . .