Dear All
I am preparing myself for the Certification exam, I am going to have it in 1 week and half. So while studying using the SCPJ 6 Study guide book, I stumbled on the following
test sample that confuse me.
In chapter 10 the following test is
What is the result? (Choose all that apply.)
A. 5 6 5 6
B. 5 6 followed by an exception
C. Compilation fails with an error on line 6
D. Compilation fails with an error on line 7
E. Compilation fails with an error on line 8
F. Compilation fails with an error on line 9
The correct Answers are: C, D and E are correct. Variable a (default access) cannot be accessed from outside the package. Since variable b is protected, it can be accessed only through inheritance.
The wrong answers are: A, B, and F are incorrect based on the above. (Objectives 1.1, 7.1)
Now the doubt: I am really feeling frustated because this is strange behaviour, my understanding was based on the explanation provided on chapter 1 page 32 to 36.
Why F is not included (I run the test on the computer and it does not consider as an error condition)
Please could you explain me why "new Fiz().b" does not thrown a compilation error as "new Foo().b" does. For me I can not find the logic behind.
Thank for any help provided.