Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 4.5 Databases

Authors: Sandeep Chanda, Damien Foggon

3rd Edition

1430243805, 978-1430243809

More Books

Students also viewed these Databases questions

Question

=+differences in home- and host-country costs of living?

Answered: 1 week ago

Question

=+derived from the assignment will balance the costs?

Answered: 1 week ago