Hi .. kindly tell me the error in the following code
package test1;
public class Test1 {
static int x = 42;
}
package test2;
public class Test2 extends test1.Test1 {
public static void main(String args[]) {
System.out.println("x="+x); } }
>Hi .. kindly tell me the error in the following code
Please tell what the problem is, quoting the error message verbatim.
It is annoying to be given guessing games. Teachers give students
guessing games, not the reverse.
Presumably your problem is that x is default rather than protected
scope, thus classes in package test2 can't see it.
see http://mindprod.com/jgloss/scope.html
>package test1;
>public class Test1 {
[quoted text clipped - 5 lines]
>public static void main(String args[]) {
>System.out.println("x="+x); } }

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.