Question: 1 . Write the code to find the position of the smallest element in an array of integers 2 . Write the code to find
Write the code to find the position of the smallest element in an array of integers
Write the code to find the average of the elements in an array of integers
Create a dogArray static variable in an AnimalShelther class
Create the following two methods in the AnimalShelter class.
a addAnimal: this method accepts an Dog object and puts it into the dog array. Dont forget to increment the number of animals.
b addAnimal: an overloaded method that accepts the inputs needed to create a Dog instance. Instantiate a dog and add it to the array.
Modify the toString in the Dog class so that it prints the name and age separated by a space.
Modify the toString for the AnimalShelter class so that it prints all the animals in the shelter dont delete what is already there, add to itYou are going to be calling the toString of the Dog class to help with this
Create a driver class. Inside the main method, create a shelter variable, add at least one animal, and print the shelter. Experiment with adding more dogs to your shelter and printing the shelter.
Update the add methods to the AnimalShelter class in the Animal Shelter project to maintain a sorted collection.
Create a remove method in the AnimalShelter class that accepts an Animal to remove. This method should return true if the animal was in the collection and has been removed, and false if the animal was not in the collection. Make sure the collection stays sorted
Consider the following diagram
Check each of the statements that are logically and syntactically correct according to the structure diagram above.
a Rodent rod new Rat;
b Rodent rod new FieldMouse;
c Mouse mou new Rat;
d Mouse mou new Rodent;
e Rat rat new Rodent;
f Rat rat new LabRat;
g Rat rat new FieldMouse;
h Rat rat new Mouse;
Consider the following declarations
class Fruit
class Apple extends Fruit
class Orange extends Fruit
class GoldenDelicious extends Apple
class McIntosh extends Apple
public class Driver
public static void mainString args
Fruit f new GoldenDelicious;
Orange o new Orange;
Using the classes above, indicate each of the following statements that returns true.
a System.out.printlnf instanceof Fruit;
b System.out.printlnf instanceof Orange;
c System.out.printlnf instanceof Apple;
d System.out.printlnf instanceof GoldenDelicious;
e System.out.printlnf instanceof McIntosh;
f System.out.printlno instanceof Orange;
g System.out.printlno instanceof Fruit;
h System.out.printlno instanceof Apple;
Fill in the blank
a When two methods in the same class have the same name but different signatures it is called
b There are several methods with the same signature. When the correct method is chosen at runtime based on the type of the invoking object, it is called
c When two methods in different classes have the same name and the same signatures it is called
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
