Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Protected method in a packaged superclass not being called by subclass  RSS feed

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,
This is my first post to this forum. I have started preparing for SCJP recently and I am totaly confused with the following code.
Can't find an answer by myself.

Fruit.java is in a package foo.

package foo;
public class Fruit
{
protected void k()
{
}
}



And implementing class Apple is having default access.

import foo.Fruit;
class Apple extends Fruit
{
public static void main(String a[])
{
Fruit b = new Apple();///Code fails to compile...If the new Apple object is assigned to a Apple b object then it runs fine...
b.k();
}
}



What am I missing here? Thanks...
 
kunal Agarwal
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Report post to moderator
I think this is not the correct place to ask this question.
I have posted it in the Beginning Java forum. Thanks...
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!