decoration decoration
Stories

GROKLAW
When you want to know more...
decoration
For layout only
Home
Archives
Site Map
Search
About Groklaw
Awards
Legal Research
Timelines
ApplevSamsung
ApplevSamsung p.2
ArchiveExplorer
Autozone
Bilski
Cases
Cast: Lawyers
Comes v. MS
Contracts/Documents
Courts
DRM
Gordon v MS
GPL
Grokdoc
HTML How To
IPI v RH
IV v. Google
Legal Docs
Lodsys
MS Litigations
MSvB&N
News Picks
Novell v. MS
Novell-MS Deal
ODF/OOXML
OOXML Appeals
OraclevGoogle
Patents
ProjectMonterey
Psystar
Quote Database
Red Hat v SCO
Salus Book
SCEA v Hotz
SCO Appeals
SCO Bankruptcy
SCO Financials
SCO Overview
SCO v IBM
SCO v Novell
SCO:Soup2Nuts
SCOsource
Sean Daly
Software Patents
Switch to Linux
Transcripts
Unix Books

Gear

Groklaw Gear

Click here to send an email to the editor of this weblog.


You won't find me on Facebook


Donate

Donate Paypal


No Legal Advice

The information on Groklaw is not intended to constitute legal advice. While Mark is a lawyer and he has asked other lawyers and law students to contribute articles, all of these articles are offered to help educate, not to provide specific legal advice. They are not your lawyers.

Here's Groklaw's comments policy.


What's New

STORIES
No new stories

COMMENTS last 48 hrs
No new comments


Sponsors

Hosting:
hosted by ibiblio

On servers donated to ibiblio by AMD.

Webmaster
14. Inheritance does not exist among packages | 314 comments | Create New Account
Comments belong to whoever posts them. Please notify us of inappropriate comments.
14. Inheritance does not exist among packages
Authored by: ais523 on Saturday, May 05 2012 @ 01:49 PM EDT
Classes can inherit from each other, just as in C++. (There are several models
of object orientation floating around, but Java's model of inheritance is pretty
much a simplified version of C++'s.) Meanwhile, package naming has nothing to do
with inheritance at all, nor is there any requirement in theory (or often in
practice) that inheritance respect package boundaries. So in the context of
packages, rather than classes, inheritance does indeed not exist.

[ Reply to This | Parent | # ]

14. Inheritance does not exist among packages
Authored by: Anonymous on Saturday, May 05 2012 @ 04:16 PM EDT
He was saying "Inheritance does not exist among packages".

Inheritance is the "is-a" relationship between two classes (and/or
"interfaces", as abstract classes with no implementation in them are
called in Java).

If you have a "class Animal", and you make a "class Cat"
that "extends Animal", then it means that every Cat object (i.e. every
instance of the Cat class) "is-a" Animal. So it's a Cat, but part of
being a Cat is that it "is-a" Animal, so you can think of it, and use
it, as an Animal too.

Inheritance is always a property of a pair of classes. The "base
class" Animal, has a "subclass" Cat. To the Cat class, its
"superclass" is Animal. Any methods or instance variables in the
Animal class are also available in Cat; the programmer writing the Cat class can
also choose to override those methods with new ones, and of course he can add
new Cat-specific methods and instance variables in the Cat class.

Note that "Animal" class and "Cat" class might be in the
same package, or they could be in two different packages--it doesn't matter at
all. "Being in the same package" is only useful for a couple of
things in the Java language; one of them is using the "default" access
control for a method or instance variable (which could be described as
"private access, except that other classes in the same package as this
class have public access". This is not something that ever plays a role in
APIs, its just a convenience feature for implementors.

[ Reply to This | Parent | # ]

Groklaw © Copyright 2003-2013 Pamela Jones.
All trademarks and copyrights on this page are owned by their respective owners.
Comments are owned by the individual posters.

PJ's articles are licensed under a Creative Commons License. ( Details )