Looking for answers? Westonci.ca is your go-to Q&A platform, offering quick, trustworthy responses from a community of experts. Ask your questions and receive accurate answers from professionals with extensive experience in various fields on our platform. Join our Q&A platform to connect with experts dedicated to providing accurate answers to your questions in various fields.
Sagot :
Answer and Explanation:
public class Main {
int Carmodel;
int Purchaseprice;
int Currentyear;
Public void setPurchasePrice(int Purchaseprice){
this.Purchaseprice=Purchaseprice;
}
Public void getPurchasePrice(){
return Purchaseprice;
}
static void printInfo(int Carmodel int Currentyear ){
this.Carmodel=Carmodel;
this.Currentyear=Currentyear;
System.out.println(getPurchasePrice() Carmodel Currentyear);
}
}
The above java program defines a class that has three methods, a get method that returns purchase price of the object, a set method that sets purchase price of the object, and a print method that print out the information about the car object(model, year, price). The print method also takes arguments and assigns values of the arguments/parameters to the object, then prints all.
We hope you found this helpful. Feel free to come back anytime for more accurate answers and updated information. Thanks for using our service. We're always here to provide accurate and up-to-date answers to all your queries. We're glad you visited Westonci.ca. Return anytime for updated answers from our knowledgeable team.