For the question one. check page 495
1. A way to discover which of two classes is the base class and which is the subclass is
a. look at the class size
b. try saying the two class names together
c. use polymorphism
d. Both a and b are correct.
2. Employing inheritance reduces errors because .
a. the new classes have access to fewer data fields
b. the new classes have access to fewer methods
c. you can copy methods that you already created
d. many of the methods you need have already been used and tested
3. A base class can also be called a .
a. child class
c. derived class
4. Which of the following choices is the best example of a parent class/child class
5. The Java keyword that creates inheritance is .
6. A class named Building has a public, nonstatic method named getFloors(). If
School is a child class of Building, and modelHigh is an object of type School, which
of the following statements is valid?
d. All of the previous statements are valid.
7. Which of the following statements is true?
a. A child class inherits from a parent class.
b. A parent class inherits from a child class.
c. Both of the preceding statements are true.
d. Neither a nor b is true.
8. When a subclass method has the same name and argument types as a superclass
method, the subclass method the superclass method.
9. When you instantiate an object that is a member of a subclass, the
constructor executes first.
b. child class
c. extended class
d. parent class
10. The keyword super always refers to the of the class in which you
a. child class
b. derived class
d. parent class
11. If the only constructor in a superclass requires arguments, its
a. must contain a constructor
b. must not contain a constructor
c. must contain a constructor that requires arguments
d. must not contain a constructor that requires arguments
12. If a superclass constructor requires arguments, any constructor of its subclasses must
call the superclass constructor .
a. as the first statement
b. as the last statement
c. at some time
d. multiple times if multiple arguments are involved
13. A child class Motorcycle extends a parent class Vehicle. Each class constructor
requires one String argument. The Motorcycle class constructor can call the
Vehicle class constructor with the statement .
d. none of the above
14. In Java, the concept of keeping data private is known as .
b. information hiding
c. data deception
d. concealing fields
15. If you create a data field or method that is , it can be used within its
own class or in any classes extended from that class.
d. both a and b
16. Within a subclass, you cannot override methods.
17. You call a static method using .
a. the name of its class, a dot, and the method name
b. the name of the class's superclass, a dot, and the method name
c. the name of an object in the same class, a dot, and the method name
d. either a or b
18. You use a method access specifier when you create methods for
which you want to prevent overriding in extended classes.
19. A compiler can decide to a final method—that is, determine the
code of the method call when the program is compiled.
20. When a parent class contains a static method, child classes
Recently Asked Questions
- Suppose a consumer has a utility function defined by U = X1/2Y1/2 (MRS = Y/X) and she has an income of $312. Suppose this individual faces the following
- Consider the following school choice problem with five students 1, 2, 3, 4, 5 and five schools a, b, c, d, and e with each school having exactly one seat. The
- 1, Swifty Corporation will receive $21500 today (January 1, 2017), and also on each January 1st for the next five years (2018 – 2022). What is the present