What is the result? 10/29/2018 – by Mod_GuideK 2 Given: What is the result? A. 200.0 : 100.0 B. 400.0 : 200.0 C. 400.0 : 100.0 D. Compilation fails. SHOW ANSWERSCorrect Answer: C Explanation/Reference: Explanation/Reference: Download Printable PDF. VALID exam to help you PASS.
public class Product { double price; } 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; double newPrice=100; Test test = new Test(); test.updatePrice(prt,newPrice); System.out.println(prt.price+”:”+newPrice); } } Reply
public class Product {
double price;
}
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;
double newPrice=100;
Test test = new Test();
test.updatePrice(prt,newPrice);
System.out.println(prt.price+”:”+newPrice);
}
}
C:
# java Test3
400.0 : 100.0