-
Notifications
You must be signed in to change notification settings - Fork 1
Module 8 Mastery Check
wolvesled edited this page Sep 5, 2013
·
1 revision
- Using the code from Project 8-1, put the ICharQ interface and its three implementations into a package called QPack. Keeping the queue demonstration class IQDemo in the default package, show how to import and use the classes in QPack. Answer: import QPack; and then refer those classes as normal.
- What is a namespace? Why is it important that Java allows you to partition the namespace? Answer: each package partition an isolated namespace from other. it allows programmer to group java files that is closely related, and having the ability to coexist same named classes under different packages.
- Packages are stored in_________. Answer: Directories of the same name with the package, in a hierarchy.
- Explain the difference between protected and default access. Answer: default access only allow the public access of the class within the same package. protected access allows not only the public access within the same package, but also all the subclasses that not in the same package.
- Explain the two ways that the members of a package can be used by other package. Answer: without import the package, use the fully qualified class name: package1.package2...Class Or use import package1.package2...Class and use Class as normal.
- "One interface, multiple methods" is a key tenet of Java. What feature best exemplifies it? Answer: polymorphism.
- How many classes can implement an interface? How many interfaces can a class implement? Answer: NO limit for both scenario.
- Can interfaces be extended? Answer: Yes.
- Create an interface for the Vehicle class from Module 7. Call the interface IVehicle.
- Variables declared in an interfaces are implicitly static and final. What good are they? Answer: As interface cannot be instantiated, so there is no way for instance variable, thus all variables declared in interfaces are static and final, this allows to define a interface with set of common constants that will be used in many places, then just implement the interface in that situation to reuse the data.
- A package is, in essense, a container for classes. True or False? Answer: True.
- What standard Java package is automatically imported into a program? Answer: java.lang