At first site,i think this program will run successfully and will print "8" on the console. This is simple concept of static and protected, as outside the package,protected will be available to subclasses only and your test class is subclass of pack so now protected will be available. now two condition can occur: if 1) protected variable is instance 2) protected variable is static
1) In first case, you need to construct an Object first then only you can refer to that variable.
2) As now it is static so you can refer by className.variableName
And yes while replying to this question I have assumed that both test and pack are different.I mean to say we have two source file pack.java and test.java.
If not then your program will not compile because pack is public and and test is default and you have defined main in test( compile time error ) and also improper place of import statement (compile time error) [ February 19, 2008: Message edited by: Sunny Jain ]