|
1. Choose one from problems
7.55 and 7.56 in the textbook
7.55
The output is
getData1
outputs: 0
(default value for int data type)
getData2
outputs: 1
(value of the instance variable)
getData3
outputs: null
(by default, there is not data stored for a point)
getData4
outputs: java.awt.Point [x=0; y=0]
(The default point for a new constructor
Point is 0,0)
2. Re-implement the power()
methods of Listing 7.7 in the textbook to work for an arbitrary integer
power n.
The obvious answer is to use to Math.pow method. Listing 7.7 cannot
process negative powers since the counter won't increment with a negative
number.
See attached file
Send me email
Visit my website
|