Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2006

Tip: Looking for answers? Try searching our database.

different inheritence depending on package

Thread view: 
Frank Fredstone - 14 Sep 2006 02:49 GMT
What am I doing wrong here. These classes in 3 separate files, compile:

// SuperValue.java
public enum SuperValue { A, B; }

// Super.java
public abstract class Super {
 abstract SuperValue method();
}

// Sub.java
public class Sub extends Super {
 public SuperValue method() { return SuperValue.A; }
}

but, if I put them in packages:

// test/SuperValue.java
package test;
public enum SuperValue { A, B; }

// test/Super.java
package test;
public abstract class Super {
 abstract SuperValue method();
}

// test/sub/Sub.java
package test.sub;
import test.SuperValue;
import test.Super;
public class Sub extends Super {
 public SuperValue method() { return SuperValue.A; }
}

javac complains that Sub is not abstract and does not override method method.
Manish Pandit - 14 Sep 2006 04:10 GMT
Hi Frank,

This is because the abstract method you declared is default (package)
scoped. It is not visible outside the current package. If you change
the signature from

abstract SuperValue method();

to public abstract SuperValue method();

it will compile and work fine.

-cheers,
Manish


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.