java ch10

27 Questions  I  By Bing22
Please take the quiz to rate it.

Java Quizzes & Trivia
Java ch10

  
Changes are done, please start the quiz.


Questions and Answers

Removing question excerpt is a premium feature

Upgrade and get a lot more done!
  • 1. 
    10.1 Q1: Polymorphism enables you to:
    • A. 

      A. program in the general.

    • B. 

      B. program in the specific.

    • C. 

      C. absorb attributes and behavior from previous classes.

    • D. 

      D. hide information from the user. d. hide information from the user.


  • 2. 
    10.1 Q2: Which of the following statements about interfaces is false?
    • A. 

      A. An interface describes a set of methods that can be called on an object, providing a default implementation for the methods.

    • B. 

      B. An interface describes a set of methods that can be called on an object, not providing concrete implementation for the methods.

    • C. 

      C. Interfaces are useful when attempting to assign common functionality to possibly unrelated classes.

    • D. 

      D. Once a class implements an interface, all objects of that class have an is-a relationship with the interface type.


  • 3. 
    10.2 Q1: For which of the following would polymorphism not provide a clean solution?
    • A. 

      A. A billing program where there is a variety of client types that are billed with different fee structures.

    • B. 

      B. A maintenance log program where data for a variety of types of machines is collected and maintenance schedules are produced for each machine based on the data collected.

    • C. 

      C. A program to compute a 5% savings account interest for a variety of clients.

    • D. 

      D. An IRS program that maintains information on a variety of taxpayers and determines who to audit based on criteria for classes of taxpayers.


  • 4. 
    10.2 Q2: Polymorphism allows for specifics to be dealt with during:
    • A. 

      A. execution.

    • B. 

      B. compilation.

    • C. 

      C. programming.

    • D. 

      D. debugging.


  • 5. 
    10.3 Q1: Which statement best describes the relationship between superclass and subclass types?
    • A. 

      A. A subclass reference cannot be assigned to a superclass variable and a superclass reference cannot be assigned to a subclass variable.

    • B. 

      B. A subclass reference can be assigned to a superclass variable and a superclass reference can be assigned to a subclass variable.

    • C. 

      C. A superclass reference can be assigned to a subclass variable, but a subclass reference cannot be assigned to a superclass variable.

    • D. 

      D. A subclass reference can be assigned to a superclass variable, but a superclass reference cannot be assigned to a subclass variable.


  • 6. 
    10.4 Q1: A(n)          class cannot be instantiated.
    • A. 

      A. final.

    • B. 

      B. concrete.

    • C. 

      C. abstract.

    • D. 

      D. polymorphic.


  • 7. 
    10.4 Q2: Non-abstract classes are called:
    • A. 

      A. real classes.

    • B. 

      B. instance classes.

    • C. 

      C. implementable classes.

    • D. 

      D. concrete classes.


  • 8. 
    10.5 Q1: It is a UML convention to denote the name of an abstract class in:
    • A. 

      A. bold.

    • B. 

      B. italics.

    • C. 

      C. a diamond.

    • D. 

      D. there is no convention of the UML to denote abstract classes—they are listed just as any other class.


  • 9. 
    10.5 Q2: If the superclass contains only abstract method declarations, the superclass is used for:
    • A. 

      A. implementation inheritance.

    • B. 

      B. interface inheritance.

    • C. 

      C. Both. d. Neither.

    • D. 

      C. Both.


  • 10. 
    10.5.1 Q1: Which of the following could be used to declare abstract method method1 in abstract class Class1 (method1 returns an int and takes no arguments)?
    • A. 

      A. public int method1();

    • B. 

      B. public int abstract method1();

    • C. 

      C. public abstract int method1();

    • D. 

      D. public int nonfinal method1();


  • 11. 
    10.5.1 Q2: Which of the following statements about abstract superclasses is true?
    • A. 

      A. abstract superclasses may contain data.

    • B. 

      B. abstract superclasses may not contain implementations of methods.

    • C. 

      C. abstract superclasses must declare all methods as abstract.

    • D. 

      D. abstract superclasses must declare all data members not given values as abstract.


  • 12. 
    Consider the abstract superclass below:public abstract class Foo{   private int a;   public int b;   public Foo( int aVal, int bVal )   {      a = aVal;      b = bVal;   } // end Foo constructor   public abstract int calculate();} // end class FooAny concrete subclass that extends class Foo:
    • A. 

      A. Must implement a method called calculate.

    • B. 

      B. Will not be able to access the instance variable a.

    • C. 

      C. Neither (a) nor (b).

    • D. 

      D. Both (a) and (b)


  • 13. 
    10.5.5 Q1: Consider classes A, B and C, where A is an abstract superclass, B is a concrete class that inherits from A and C is a concrete class that inherits from B. Class A declares abstract method originalMethod, implemented in class B. Which of the following statements is true of class C?
    • A. 

      A. Method originalMethod cannot be overridden in class C—once it has been implemented in concrete class B, it is implicitly final.

    • B. 

      B. Method originalMethod must be overridden in class C, or a syntax error will occur.

    • C. 

      C. If method originalMethod is not overridden in class C but is called by an object of class C, an error occurs.

    • D. 

      D. None of the above.


  • 14. 
    10.5.6 Q1: When a superclass variable refers to a subclass object and a method is called on that object, the proper implementation is determined at execution time. What is the process of determining the correct method to call?
    • A. 

      A. execution time binding.

    • B. 

      B. execution binding.

    • C. 

      C. just-in-time binding.

    • D. 

      D. late binding.


  • 15. 
    10.5.6 Q2: Every object in Java knows its own class and can access this information through method         .
    • A. 

      A. getClass.

    • B. 

      B. getInformation.

    • C. 

      C. objectClass.

    • D. 

      D. objectInformation.


  • 16. 
    10.5.7 Q1: Assigning a subclass reference to a superclass variable is safe:
    • A. 

      A. because the subclass object has an object of its superclass.

    • B. 

      B. because the subclass object is an object of its superclass.

    • C. 

      C. only when the superclass is abstract.

    • D. 

      D. only when the superclass is concrete.


  • 17. 
    10.6 Q1: Classes and methods are declared final for all but the following reasons:
    • A. 

      A. final methods allow inlining the code.

    • B. 

      B. final methods and classes prevent further inheritance.

    • C. 

      C. final methods are static.

    • D. 

      D. final methods can improve performance.


  • 18. 
    10.6 Q2: All of the following methods are implicitly final except:
    • A. 

      A. a method in an abstract class.

    • B. 

      B. a private method.

    • C. 

      C. a method declared in a final class.

    • D. 

      D. static method.


  • 19. 
    10.6 Q3: Declaring a method final means:
    • A. 

      A. it will prepare the object for garbage collection.

    • B. 

      B. it cannot be accessed from outside its class.

    • C. 

      C. it cannot be overloaded.

    • D. 

      D. it cannot be overridden.


  • 20. 
    10.7 Q1: An interface may contain:
    • A. 

      A. private static data and public abstract methods.

    • B. 

      B. only public abstract methods.

    • C. 

      C. public static final data and public abstract methods.

    • D. 

      D. private static data and public final methods.


  • 21. 
    Which of the following does not complete the sentence correctly?An interface         .
    • A. 

      A. forces classes that implement it to declare all the interface methods.

    • B. 

      B. can be used in place of an abstract class when there is no default implementation to inherit.

    • C. 

      C. is declared in a file by itself and is saved in a file with the same name as the interface followed by the .java extension.

    • D. 

      D. can be instantiated.


  • 22. 
    10.7.1 Q1: The UML distinguishes an interface from other classes by placing the word “interface” in          above the interface name.
    • A. 

      A. italics.

    • B. 

      B. carets.

    • C. 

      C. guillemets.

    • D. 

      D. bold.


  • 23. 
    10.7.2 Q1: Interfaces can have          methods.
    • A. 

      0

    • B. 

      1

    • C. 

      2

    • D. 

      D. any number of


  • 24. 
    10.7.3 Q1: Which keyword is used to specify that a class will define the methods of an interface?
    • A. 

      A. uses.

    • B. 

      B. implements.

    • C. 

      C. defines.

    • D. 

      D. extends.


  • 25. 
    10.7.3 Q2: Which of the following is not possible?
    • A. 

      A. A class that implements two interfaces.

    • B. 

      B. A class that inherits from two classes.

    • C. 

      C. A class that inherits from one class, and implements an interface.

    • D. 

      D. All of the above are possible.


  • 26. 
    10.7.4 Q1: A class that implements an interface but does not declare all of the interface’s methods must be declared:
    • A. 

      A. public.

    • B. 

      B. interface.

    • C. 

      C. abstract.

    • D. 

      D. final.


  • 27. 
    10.7.7 Q1: Constants declared in an interface are implicitly         .
    • A. 

      A. private.

    • B. 

      B. static.

    • C. 

      C. abstract.

    • D. 

      D. All of the above.


Back to top

Removing ad is a premium feature

Upgrade and get a lot more done!
Take Another Quiz
We have sent an email with your new password.