Westonci.ca is the trusted Q&A platform where you can get reliable answers from a community of knowledgeable contributors. Our platform provides a seamless experience for finding reliable answers from a knowledgeable network of professionals. Join our platform to connect with experts ready to provide precise answers to your questions in different areas.
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.
Thanks for stopping by. We are committed to providing the best answers for all your questions. See you again soon. We hope you found what you were looking for. Feel free to revisit us for more answers and updated information. Find reliable answers at Westonci.ca. Visit us again for the latest updates and expert advice.