|
Note | The solutions to these exercises are in Appendix B. |
Suppose package superpack contains subpackage subpack. Suppose a source file contains the following line:
import superpack.*;
Will this line import classes in subpack? Write code to support your answer.
Create a class that illegally tries to read a private variable of another class. What is the point of this exercise?
Create a class that illegally tries to call a default-access method of another class.
Create a class that illegally tries to write a protected variable of another class.
True or false: If a class has at least one abstract method, the class must be abstract. Write code to support your answer.
True or false: If a class is abstract, it must have at least one abstract method. Write code to support your answer.
Write an application that tries to construct an instance of an abstract class. Can you compile the application? Can you execute it?
|