Multiple Choice
Consider the following class:
Public class Auto
{
Private String make;
Private String model;
Private String year;
Public Auto(String aMake, String aModel, String aYear)
{
Make = aMake;
Model = aModel;
Year = aYear;
}
Public String calcMileage(double milesDriven, double gasUsed)
{
Double milage = milesDriven/gasUsed;
Return mileage.toString() ;
}
}
Which of the following code snippets will correctly create an object of type Auto and display its mileage?
A) myAuto = new Auto() ;
System.out.println(myAuto.calcMileage(246.0, 15.8) ) ;
B) Auto myAuto = new Auto() ;
System.out.println(myAuto.calcMileage(246.0, 15.8) ) ;
C) Auto myAuto = new Auto("2011", "Ford", "Focus") ;
System.out.println(myAuto.calcMileage(246.0, 15.8) ) ;
D) Auto myAuto = new Auto("Ford", "Focus", "2011") ;
System.out.println(myAuto.calcMileage(246.0, 15.8) ) ;
Correct Answer:

Verified
Correct Answer:
Verified
Q19: Complete the following code snippet to create
Q20: Insert the missing code in the following
Q21: You have created a Motorcycle class which
Q22: Insert the missing code in the following
Q23: Consider the following code snippet:<br>Public class Vehicle<br>{<br>Private
Q25: Which choice indicates that a string variable
Q26: Which statement calls a constructor with no
Q27: Consider the following code snippet:<br>Public class Transaction<br>{<br>Private
Q28: Which of the following statements about class
Q29: If you do not provide a constructor