Week 9 - Homework 5

 

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

 


 

Home | Photos | Favorite Links | Matt's Bio

UMUC | Feedback | Guest book | E-mail me

 

FaulknerWeb.com is designed and managed by Matt Faulkner

Domain Name service provided by Namesecure

Web Service by eDataRack
Copyright © 1998 - 2009 [FaulknerWeb.com]. All rights reserved.
Updated: June 16, 2009 09:35 .