Starting from:

$17

Chapter 7 - Self Test Exercises.java_ soln Q. 1-23

Exercise 1 Suppose the class named DiscountSale is derived class of a class called Sale. Suppose the class Sale hase instance variables named "price" and "numberOfItems". Will an object of the class DiscountSale also have instance variables named "price" and "numberOfItems"? 2 3 4 5 6 7 8 9 10 11 12 13 14 Exercise 15: Redefine the equals method for the class HourlyEmployee (check in Eclipse) using super.equals to invoke the equals method of the base class Employee. 16 17 18 19 20 21 22 23: Exercise 23: (This exercise requires that you have covered the starred subsection “An Enhanced StringTokenizer Class *,” earlier in this chapter.) Although we did not discuss it when we covered the class StringTokenizer, the class StringTokenizer has a method with the following heading: public Object nextElement() The method nextElement() returns the same string as the method nextToken(), but nextElement() returns it as something of type Object, as opposed to type String. Give a suitable definition of nextElement to add to the definition of EnhancedStringTokenizer. This definition will override the definition of nextElement in the class StringTokenizer. (Hint : the definition is just like the definition of nextToken except for fixing the type of the string returned.)

More products