30 public class WarmUp{ public static void main(String[] args) { Door door new Door (100.00); House...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
30 public class WarmUp{ public static void main(String[] args) { Door door new Door (100.00); House cheapHouse = new House (door); 1 class House{ 2 private Door door; 31 3 32 4 public House (Door some Door) { 33 5 door someDoor; 34 6 } 35 7 36 8 public String toString() { 37 9 return ""+door; 38 10 } 39 11 } 40 12 41 } 13 class Door{ door.setPrice(999.99); House exspensiveHouse = new House(door); System.out.println("Cheap house :"+cheapHouse); System.out.println("Exspensive house :"+exspensiveHouse); public Door (double doorPrice){ price doorPrice; public void setPrice(double doorPrice){ 14 private double price; 15 16 17 18 } 19 20 21 22 } 23 24 public String toString(){ 25 return " door price: "+price; 26 } 27 } price doorPrice; 42 43} What will be the door price for the cheapHouse? Hint: Check how the House constructor is assigning the instance field door. 1 class Car{ 2 3 int numWheels; 4 public Car(int numWheels){ What will value will be printed out for num Wheels? 6 } 7 numWheels numWheels; public String toString() { return "Num wheels : "+numWheels; A.) 4 B.) O C.) Compiler Error D.) 2 9 89 } 10 11 } 12 13 public class Garage{ 14 15 16 public static void main(String[] args) { Car carl = new Car (4); System.out.println(car1); 17 } 18 } Hint: Look at the previous slides and check what happens when "shadowing" occurs. 30 public class WarmUp{ public static void main(String[] args) { Door door new Door (100.00); House cheapHouse = new House (door); 1 class House{ 2 private Door door; 31 3 32 4 public House (Door some Door) { 33 5 door someDoor; 34 6 } 35 7 36 8 public String toString() { 37 9 return ""+door; 38 10 } 39 11 } 40 12 41 } 13 class Door{ door.setPrice(999.99); House exspensiveHouse = new House(door); System.out.println("Cheap house :"+cheapHouse); System.out.println("Exspensive house :"+exspensiveHouse); public Door (double doorPrice){ price doorPrice; public void setPrice(double doorPrice){ 14 private double price; 15 16 17 18 } 19 20 21 22 } 23 24 public String toString(){ 25 return " door price: "+price; 26 } 27 } price doorPrice; 42 43} What will be the door price for the cheapHouse? Hint: Check how the House constructor is assigning the instance field door. 1 class Car{ 2 3 int numWheels; 4 public Car(int numWheels){ What will value will be printed out for num Wheels? 6 } 7 numWheels numWheels; public String toString() { return "Num wheels : "+numWheels; A.) 4 B.) O C.) Compiler Error D.) 2 9 89 } 10 11 } 12 13 public class Garage{ 14 15 16 public static void main(String[] args) { Car carl = new Car (4); System.out.println(car1); 17 } 18 } Hint: Look at the previous slides and check what happens when "shadowing" occurs.
Expert Answer:
Answer rating: 100% (QA)
In the given code snippets there are a couple of issues related to variable assignment that need to ... View the full answer
Related Book For
Java How To Program Late Objects Version
ISBN: 9780136123712
8th Edition
Authors: Paul Deitel, Deitel & Associates
Posted Date:
Students also viewed these programming questions
-
If the focal length of a lens is 3 centimeters and the image distance is 5 centimeters from the lens, what is the distance from the object to the lens?
-
(20 points)Write a program that prompts the user to input five decimal numbers. The program should then add the five decimal numbers, convert the sum to the nearest integer, and print the result....
-
Use the data in the table to complete the following. (a) Make a scatterplot of the data. Estimate a value for b so that f(x) = 0.0002x b models the data. (b) Check the accuracy of f(x). (c) The moon...
-
Access the annual financial statements of Stora Enso Oyj for the company's year ended December 31, 2014. These are available at the company's website, www.storaenso.com. Review the information that...
-
A chain of length L and mass m is held vertically so that the bottom link just touches the floor. It is then dropped. (a) Show that the acceleration of the top end of the chain is g. (b) If the chain...
-
A Carnot refrigerator rejects \(3000 \mathrm{kj}\) of heat at \(400 \mathrm{k}\) while using \(1000 \mathrm{kj}\) of work. The lowest operating temperature in the cycle should be: (a) \(15^{\circ}...
-
Ada Fontanez is the president of a large company that owns a chain of athletic shoe stores. The company was in dire financial condition when she was hired three years ago. In an effort to motivate...
-
: The system of forces shown in figure is in equilibrium Calculate the unknown force 'P' and angle '0'. P 60 N 45 100 N 60 40 N 80 N
-
Metro Land is a country located on a 2D Plane. They are having asummer festival for everyone in the country and would like tominimize the overall cost of travel for their citizens. Costs oftravel are...
-
#include #include int fun(int *ptr, int *z); void main() { int i; int "ptr = NULL; int y = 0; int #z = NULL; ptr = malloc(10* sizeof(int)); z = malloc(sizeof(int)); for(i=0;i <5;i++){ *(ptr +1)=(i*...
-
How to write a formal refusal letter letting him/her know your decision with example?
-
Explain the difference between a contest and a sweepstakes and a lottery. Make sure you explain what counts as consideration.
-
How to Evaluate the Effectiveness of your message. Evaluate a message to judge its effectiveness.
-
Write two or three paragraphs regarding what you have learned about the World Federation of the Deaf, its core values, mission, and especially why they are doing the International Week of Deaf.
-
A person works and earns $ 2,535.00 but on a pay stub pays 6.5% to tax. How much money is left over after taxes? Explain
-
For 11.20 kg of a magnesium-lead alloy of composition 30 wt% Pb-70 wt% Mg. is it possible, at equilibrium, to have a and Mg,Pb phases having respective masses of 7.39 and 3.81 kg? If so, what will be...
-
[a] Two foam blocks, each with a charge of 19 micro coulombs (1 C = 10-6 C), are both held in place 19 cm apart in the east-west direction. A foam ball with a charge 49 C is placed 55 cm north of the...
-
Implement the Shape hierarchy shown in Fig. 9.3. Each Two-DimensionalShape should contain method getArea to calculate the area of the two-dimensional shape. Each ThreeDimensionalShape should have...
-
Create a program that reads integer grades and stores them in an ArrayList, then use stream processing to display each grades letter equivalent (A, B, C, D or F). Response to comment: I assume it is...
-
Reimplement the factorial methods of Figs. 18.3 18.4 to calculate factorials using lambdas and streams, rather than recursion. Fig. 18.3 Fig. 18.4 1 // Fig. 18.3: Factorial Calculator.java //...
-
Assuming the expectations theory is the correct theory of the term structure, calculate the interest rates in the term structure for maturities of one to four years, and plot the resulting yield...
-
Assuming the expectations theory is the correct theory of the term structure, calculate the interest rates in the term structure for maturities of one to four years, and plot the resulting yield...
-
What is a key function of credit-rating agencies? Do credit-rating agencies always provide reliable information? What was the role of credit-rating agencies in the sub-prime crisis of 2008?
Study smarter with the SolutionInn App