Welcome to Westonci.ca, the place where your questions are answered by a community of knowledgeable contributors. Join our platform to connect with experts ready to provide detailed answers to your questions in various areas. Connect with a community of professionals ready to help you find accurate solutions to your questions quickly and efficiently.
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 this was helpful. Please come back whenever you need more information or answers to your queries. We hope you found this helpful. Feel free to come back anytime for more accurate answers and updated information. Discover more at Westonci.ca. Return for the latest expert answers and updates on various topics.