Solved

Consider the Following Class

Question 24

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:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions