Stephen Lee

Greenhorn
+ Follow
since Jun 17, 2006
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Stephen Lee

Hi Everyone,

I have a question regarding the proctected modifier..
--------------

package packed;
public class pack
{
static public int x1 = 7;
protected int x2 = 8;
static int x3=9;
static private int x4 =10;
}
----

import packed.pack;
class test3 extends pack
{
public static void main( String args[] )
{
pack p = new pack();
System.out.println(p.x2);
}


}

I got an error saying that x2 is not visible on line "System.out.println(p.x2);" of test3 class.

I thought the protected modifier on variables would mean that subclasses and classes in the same package would have access to the protected variable of the parent class?

Thanks

Stephen
Hi Everyone,

I am thinking of purchasing the SUN e-practice exams from SCJP 1.5. I was wondering if anyone can comment on whether the questions found in sun e-practice exam are in the format of the real exams and whether the style of questions are close to the actual exam?

Thanks

Stephen