File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Make it so: Java DB Connections & Transactions
this week in the
protected access modifier using inheritance
Joined: Sep 18, 2012
Sep 18, 2012 00:51:10
public class A
protected int a = 10;
public static void main(
public class B extends A
public static void main(String args)
A a1 = new A();
I am getting a compilation error: 'a' has protected access in A. But protected means it can be accessible in sub class which is in different package also right
Joined: Aug 11, 2012
Sep 18, 2012 00:58:11
It's strange>>> How come, two exactly same topic with same heading and same question can be started by two different Users...
Anyways.. Lisa, you can refer to
I have given the answer for this same question..
Jesper de Jong
Joined: Aug 16, 2005
Sep 18, 2012 01:39:17
Locking this one, since it's exactly the same as the other post, even though it's by another user. (Do you have two accounts??).
Java Beginners FAQ
JavaRanch SCJP FAQ
The Java Tutorial
Java SE 8 API documentation
I agree. Here's the link:
subject: protected access modifier using inheritance
Please explain this code
Q of inner class in different package
protected method not being overridden in diff. package
About packages and complications - total confusion
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015