Question: Use the partial class definition to answer questions 1 to 5 below. public class Car { private String make; private String model; } 1. Write
Use the partial class definition to answer questions 1 to 5 below. public class Car { private String make; private String model; }
1. Write a constructor for the Car class that will accept two input arguments as the initial values of the attributes.
2. Write an overloaded constructor for the Car class that will take a single argument for the model of the car, setting the make to "unknown".
3. Write a setter method for the make attribute.
4. Write a getter method for the model attribute.
5. Complete a main method that will accomplish the following steps. (You may assume that the class includes all appropriate setter methods and getter methods for all instance variables.) Create a car with the make "Ford" and the model "Fusion". Create a car with the make "Honda" and the model "Civic". Change the model of the second car from "Civic" to "Accord". On a separate line, print the make and model values for each car.
6. Write a method that meets the requirements of the following comment header block. // // isMultiple // // The purpose of this method is to find whether or not the first // integer provided is a multiple of the second integer. In other // words, when the first integer is divided by the second, is the // remainder zero? // // Input Argument: a the first integer // b the second integer // Return Value: multiple a boolean value representing whether or not // the first integer is a multiple of the second //
7. Write a method that meets the requirements of the following comment header block. This method should use the method created in the previous problem. // // findLastMultiple // // The purpose of this method is to find the last appearance of a // multiple value within an array. When found, the method returns the // index number of the value in the array. If a multiple is not found, the // method returns -1. // // Input Arguments: values the array of values // n check for multiples of this number // Return Value: index the index of the final multiple in the array, // or -1 if no multiple is found
8. What is the result of this expression? int x = 20 + (23 / 4) % 3; a. 1 b. 8 c. 20 d. 22
9. Given the following declaration, which of the following statement is most accurate? Account x = new Account(); a. x contains a reference to an Account object. b. x contains an object of the Account type. c. You can assign an double value to x. d. x contains an double value
10. What is the keyword used to call another constructor in the same class?
11. What is the keyword used to call a constructor from the class's superclass?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
