Question: Given the following two programs, write the output of the Product App class. public class Product { private String code; private double price; public Product()

 Given the following two programs, write the output of the Product

Given the following two programs, write the output of the Product App class. public class Product { private String code; private double price; public Product() { code = ""; price = 0; } public void setCode(String c) { code c; } public String getCode() { return code; } public void set Price (double p) { price = p; } public double getPrice() { return price; } }//end of Product public class ProductApp { public static void main (String args[]) { Product p1 = new Product(); p1.setCode("Acct"); P1.setPrice (10.0); double x = p1.getPrice()*0.9; Product p2 = updatePrice(p1, x); System.out.println("price 1: "+p1.getPrice()); System out.println("price 2:" +p2.getPrice()); p2.set Price (11.0); System.out println("price 1:"+ p1.getPrice()); System out.println("price 2:" +p2.getPrice()); } static Product updatePrice(Product p, double price) { p.setPrice (price); return p; } }//end of ProductApp

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!