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
Q58: You are creating a class named Employee.
Q59: Consider the following code snippet:
Public class Vessel
{
Private
Q60: Consider the following code snippet:
Public int getCoinValue(String
Q61: Consider the following code snippet:
Public class AutoRace
{
Private
Q62: Which of the following statements about testing
Q64: Consider the following code snippet:
Public class Transaction
{
Private
Q65: You have created a Fruit class and
Q66: Consider the following code snippet:
Public class Course
{
Private
Q67: Consider the following code snippet:
Public class Vehicle
{
Private
Q68: You have created a Coin class and
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents