Java textbook answer (non-offici

2016-03-21  本文已影响18人  小简猫

//page 45 exercises

Time is money // 24
8;b //25
abcd//26 
abc // 27
def  
abc\ndef    // 28  because the // is for / not for n 
HELLO TONY// 29
2 + 2 = 4  // 30 because in the calculation the mah should be the     first 
2 + 2 = 22

// exercises 31 
public class Person {

public static void main(String[] args) {
    int sam = increaseAge(10);
    System.out.println(sam);

}

public static int increaseAge(int inAge){
    return inAge;
}
}//31

/*
exercises 32:
the test does not change to the lower case when it print out, it should change to " System.out.println(test.toLowerCase());" or "test = test.toLowerCase();" so that after the print out, the test would all be lower case.
*/

**page 80 **

chapter 7 Inheritance
// page 427 -- 461

Question: 430-464

Question: 433-467
does the parameter from the hourly employee passed from the based class and need the super (variables from the base class as well);
&& yes

Question: 438-472

Exercises: (self-test exercises 443-477)

  1. An object of the class Discount will also have instance variables named price and numberOfItems--> get variables.
  2. Yes, an object of the class DiscountSale have methods name getTotal and getTax. The methods have to perform the exact same actions in the class DiscountSale as in the class Sale if the method does not overriding by the method in the derived class.
  3. there are two methods named getTax will the class DiscountSale has and "@Overriding" should be at the heading
  4. because the name as the instance variables extends into the subclass by super so that we don't need to have the getname to get the variable;

Question: ????

Self-Text Exercises: 448-482

  1. The following program is illegal the cannot use the type of employee directly, it should use the extend to extend the method to the base class;

Question:
example: an enhanced StringTokenizer Class

Self-Text Exercises: 454-488

  1. it is legal
  2. it would then be legal to add the method crazyMethod to the class HourlyEmployee

chapter 16
chapter 17

上一篇 下一篇

猜你喜欢

热点阅读