Solved

Consider the Following Class

Question 52

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 getInfo()
{
Return year + " " + make + " " + model;
}
}
Which of the following code snippets will correctly create an object of this class and display its information?


A) myAuto = new Auto() ;
System.out.println(myAuto.getInfo() ) ;
B) Auto myAuto = new Auto() ;
System.out.println(myAuto.getInfo() ) ;
C) Auto myAuto = new Auto("Ford", "Focus", "2011") ;
System.out.println(myAuto.getInfo() ) ;
D) Auto myAuto = new Auto("2011", "Ford", "Focus") ;
System.out.println(myAuto.getInfo() ) ;

Correct Answer:

verifed

Verified

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

Related Questions