Review Questions

graphics/rq_icon.gif

4.14

Given the following class, which of these are valid ways of referring to the class from outside of the package net.basemaster?

package net.basemaster;

public class Base {
    // ...
}

Select the two correct answers.

  1. By simply referring to the class as Base.

  2. By simply referring to the class as basemaster.Base.

  3. By simply referring to the class as net.basemaster.Base.

  4. By importing with net.basemaster.* and referring to the class as Base.

  5. By importing with net.* and referring to the class as basemaster.Base.

4.15

Which one of the following class definitions is a valid definition of a class that cannot be instantiated?

Select the one correct answer.

  1. class Ghost {
           abstract void haunt();
       }
    
  2. abstract class Ghost {
           void haunt();
      }
    
  3. abstract class Ghost {
           void haunt() {};
       }
    
  4. abstract Ghost {
        abstract void haunt();
       }
    
  5. static class Ghost {
           abstract haunt();
       }
    
4.16

Which one of the following class definitions is a valid definition of a class that cannot be extended?

Select the one correct answer.

  1. class Link { }

  2. abstract class Link { }

  3. native class Link { }

  4. static class Link { }

  5. final class Link { }

  6. private class Link { }

  7. abstract final class Link { }