Ask Question
2 December, 02:52

Class Product {

double price;

}

public class Test {

public void updatePrice (Product product, double price) {

price = price * 2;

product. price=product. price + price;

}

public static void main (String args[]) {

Product prt = new Product ();

prt. price=200;

doucble newPrice = 100;

Test t = new Test ();

t. updatePrice (prt, newPrice);

System. out. println (prt. price + " : " + newPrice);

}

}

What is the result?

A) 200.0: 100.0

B) 400.0: 200.0

C) 400.0: 100.0

D) Compilation fails.

+2
Answers (1)
  1. 2 December, 05:31
    0
    C) 400.0: 100.0

    Explanation:

    prt. price = 200 and updatePrice method is called which makes it 400 & new price is as declared 100.

    Both the numbers are double hence

    400.0 : 100.0 is printed.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Class Product { double price; } public class Test { public void updatePrice (Product product, double price) { price = price * 2; product. ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers