Owl Teach Yourself Java 2 in 21 Days, Third Edition
HOME / FEEDBACK / ORDER THE BOOK / OTHER BOOKS / THANKS
ROGERS CADENHEAD

Day 6: Packages, Interfaces, and Other Class Features

Certification Practice

Each chapter of the book ends with a Certification Practice question that's comparable to what you could expect to be asked on a Java certification test. Here's the answer for chapter 6:

Answer (b) is correct. All three of these instance variables are available for use in the EvenMoreInformation class. The quantity variable is defined in the class, so it can be accessed within the class. The duration variable is defined in the Information class with the public modifier, so it can be accessed from any other class. The rate variable is defined in the Information class with the protected modifier, so it can be accessed from that class and any of its subclasses, even if they do not belong to the same package.

Answers (a), (c), and (d) are incorrect. All of them refer to average, an instance variable in the Information class defined with no modifier. Any variable defined without an access modifier can be used in that class and subclasses that belong to the same package, but not in subclasses that belong to a different package. Since the Information class is part of the com.prefect.bureau package and the EvenMoreInformation class is part of the com.prefect.bureau.us package, the average instance variable is not visible in EvenMoreInformation. Edit

Return to Day 6

   
HOME / FEEDBACK / ORDER THE BOOK / OTHER BOOKS / THANKS

Valid HTML 4.01!

Valid CSS!