Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Assignment

Using Abstract Classes and Methods Create the Java source code files for the classes listed in the inheritance hierarchy displayed in Figure 10-60a. Create a new Java source code file and enter code for the AbstractTest.java test program, as shown in Figure 10-60b. Compile all source code and execute the test program to obtain the output as displayed in Figure 10-60c. Perform the following steps to complete these tasks:

1. Create an abstract base class, Animal. The single constructor requires a String to indicate the type of animal, which then is stored in an instance variable.

2. Create a concrete class, Cat, which inherits from Animal. Cat has two instance variables, both Strings: name, which has private access and breed, which has protected access.

3. Create an abstract class, Bird, which inherits from Animal. Bird has a single instance variable, breed, of type String with protected access. Bird implements only the required move() method.

4. Create a concrete class, Robin, which inherits from Bird. Robin has a single instance variable, name, of type String with private access. Robin implements the remaining required methods.

5. Compile all source code and execute the test program to obtain the output as displayed in Figure 10-60c.

6. Create a Dog class and a Fish class, both inheriting from Animal.

7. Re-write Abstract Test (Figure 10-60b) as LoopTest.java. Create an arrray of Animal and then loop through the array using an enhanced for(), calling the describe(), sound(), sleep(), and move() methods, successively. Save and then print your source code.

8 Change LoopTest.java to use an Array List instead of an array. Print your source code and indicate whether or not your for() loop had to be modified when changing from an array to an Array List.

580_Figure 10-60a.jpg

2100_Figure 10-60b.jpg

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92775745

Have any Question?


Related Questions in Computer Engineering

Describe some of the advantages and disadvantages of using

Describe some of the advantages and disadvantages of using the N-version programming approach.

A federal agency responsible for enforcing laws governing

A federal agency responsible for enforcing laws governing weights and measures routinely inspect packages to determine whether the weight of the content is at least as great as that advertised on the package. A random sa ...

Scenario you have been asked to develop a company policy on

Scenario: You have been asked to develop a company policy on what should be done in the event of a data breach, such as unauthorized access to your company's customer database. What sort of process would you use to devel ...

We are evaluating a project that costs 1120000 has a

We are evaluating a project that costs $1,120,000, has a ten-year life, and has no salvage value. Assume that depreciation is straight-line to zero over the life of the project. Sales are projected at 64,000 units per ye ...

Question suppose we know a lt b ie a reduces to b in linear

Question : Suppose we know A (a) What can be said about the running time for A? (b) What can be said about the running time for B?

Question suppose that a simple fpga programmable switch

Question : Suppose that a simple FPGA programmable switch that has four destination points (N, S, E and W) and consists of 6 pass transistors with 6-SRAM cells to program each gate (T1, T2, T3, T4, T5, T6) is used. If th ...

Several basic principles or reasons make psychological

Several basic "principles" or reasons make psychological social engineering effective. These include authority, intimidation, consensus/social proof, scar- city, urgency, familiarity/liking, and trust. Table 2-6 in your ...

Arectangular box without a top has surface area 2500 cm2

A rectangular box without a top has surface area 2500 cm 2 . The length x of its base is 18 cm longer that its width. • (a) Use MATLAB's polynomial functions to express the volume V of the box in terms of x. • (b) Plot V ...

A compute the sumnbsps1nbsp 1 2 3 nbsp nbsp 9999 the sum

(a) Compute the sum S1 = 1 + 2 + 3 + . . . + 9999 (the sum of all integers from 1 to 9999). Do not use a program. (b) Compute the sum S2 = 1+3+5+...+9999 (the sum of all odd integers from 1 to 9999). Do not use a program ...

Could you help me to solve the following stats problemthe

Could you help me to solve the following stats problem? The number of patients waiting for flu vaccine at A hospital has the following probability distributions. x 1 2 3 4 p(x) 0.2 0.3 0.4 0.1 What is the variance of num ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As