🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: aus.computers.java
Article #251

Re: Multiple interfaces

#251
From: Lee Fesperman
Date: Sun, 23 Jun 2002 09:14
28 lines
2620 bytes
Tristan Reeves wrote:
> 
> This is quite strange, because clearly MyInterface does not "extend" Object
> in any conventional way (this is true because you can't call Object methods
> from an interface reference), and yet once the interface has been passed to
> myMethod, it seems that I have access to the Object that is implementing the
> interface - this seems possible too by a straight typecast to Object.

Actually, you can call Object methods on an interface reference, anywhere.

Basically, an interface reference contains either null or the object of some class, and 
all classes inherit from Object (except Object ... blah, blah).

So in,

public interface MyInterface { boolean equals(Object obj); }

The method declaration is redundant.

> Doesn't this break encapsulation??

I'm not sure why it would. However, it is a subtle quirk in Java.

-- 
Lee Fesperman, FirstSQL, Inc. (http://www.firstsql.com)
==============================================================
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS  (http://www.firstsql.com)
Technical Details
Message-ID: <3D15916A.1162@ix.netcom.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!howland.erols.net!newsfeed.mindspring.net.MISMATCH!newsfeed0.news.atl.earthlink.net!news.atl.earthlink.net!news.mindspring.net!not-for-mail
References: <1024283082.192985@web.apex.net.au> <JScP8.111$Fv1.17660@newsread2.prod.itd.earthlink.net> <1024289793.45649@web.apex.net.au> <pan.2002.06.17.07.46.24.235390.777@databasix.com> <3D0F7E91.5010401@krang.f9.co.uk> <3d10edc6.1491361@news.virgin.net> <3D1101BE.40506@krang.f9.co.uk> <3d121553.1321895@news.virgin.net> <3D126A72.4123E49B@i.hate.spam> <1024711986.718420@web.apex.net.au> <3D1432AC.70904@krang.f9.co.uk> <1024797220.174258@web.apex.net.au>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d6db,113f3357bc588129
X-Google-Attributes: gid10d6db,public
X-Google-Thread: 10a146,113f3357bc588129
X-Google-Attributes: gid10a146,public
X-Google-Thread: f74b3,113f3357bc588129
X-Google-Attributes: gidf74b3,public
X-Google-ArrivalTime: 2002-06-23 02:21:01 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!howland.erols.net!newsfeed.mindspring.net.MISMATCH!newsfeed0.news.atl.earthlink.net!news.atl.earthlink.net!news.mindspring.net!not-for-mail
From: Lee Fesperman <firstsql@ix.netcom.com>
Newsgroups: aus.computers.java,borland.public.jbuilder.java.language,comp.lang.java.programmer
Subject: Re: Multiple interfaces
Date: Sun, 23 Jun 2002 02:14:18 -0700
Organization: FirstSQL, Inc.
Lines: 28
Message-ID: <3D15916A.1162@ix.netcom.com>
References: <1024283082.192985@web.apex.net.au> <JScP8.111$Fv1.17660@newsread2.prod.itd.earthlink.net> <1024289793.45649@web.apex.net.au> <pan.2002.06.17.07.46.24.235390.777@databasix.com> <3D0F7E91.5010401@krang.f9.co.uk> <3d10edc6.1491361@news.virgin.net> <3D1101BE.40506@krang.f9.co.uk> <3d121553.1321895@news.virgin.net> <3D126A72.4123E49B@i.hate.spam> <1024711986.718420@web.apex.net.au> <3D1432AC.70904@krang.f9.co.uk> <1024797220.174258@web.apex.net.au>
NNTP-Posting-Host: a5.f7.cc.ab
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Server-Date: 23 Jun 2002 09:20:13 GMT
X-Mailer: Mozilla 2.01 (Win95; U)