- 3

Please I need answers for this Java questions

sing the code below determine the output of questions a) to f) public class Grape { private string color; private double price; public Grape (String color, double price) { this.color = color; this.price = price; } public Grape (double price) { ​this ("purple", price); } public string getColor() { return color; } public double getPrice() {return price; } public void setPrice (double p) {price = p; } } a) Grape a = new Grape("blue", 120.00); System.out.println(a.getColor());​​ b) System.out.println(a.getPrice());​​ c) a.setPrice(50.5); System.out.println(a.getPrice());​​ d) Grape b = new Grape(98.6); System.out.println(b.getColor());​​ e) System.out.println(b.getPrice());​​ f) b.setPrice(a.getPrice()); System.out.println(b.getPrice());

20th Jan 2021, 10:08 AM
John Wooten
John Wooten - avatar
5 Antworten
+ 2
John Wooten , it looks as this is your homework?
20th Jan 2021, 12:00 PM
Lothar
Lothar - avatar
0
This is not a question, it is a demand. You are asking for a solution, not for an answer. This doesn't qualify for Q&A. Please make an attempt and describe your individual problem
20th Jan 2021, 12:48 PM
Benjamin Jürgens
Benjamin Jürgens - avatar
0
yeah i just want you to help me with yhe answers.
20th Jan 2021, 1:15 PM
John Wooten
John Wooten - avatar
0
I just need answers to my questions
20th Jan 2021, 1:16 PM
John Wooten
John Wooten - avatar
0
Assuming you are here to learn, giving you the answers would be pointless. But here is some advice to help you: You could either just go through the questions and find the answers. It is all straight forward. You just need basic understanding of classes that you can learn from the Java course here on sololearn. This link takes you right to the classes chapter: https://www.sololearn.com/learning/1068/2151/4237/1 Or you could take the code to code playground and try yourself to see the answers. For that you need some modifications: - Put the code from a) - f) in main method - Delete some obscure characters. How did you even manage to get some 'ZERO WIDTH SPACE' characters in there?? Third possibility: pay someone. For 20€ I can give you the answers
20th Jan 2021, 3:08 PM
Benjamin Jürgens
Benjamin Jürgens - avatar