Question: 30 public class WarmUp{ public static void main(String[] args) { Door door new Door (100.00); House cheapHouse = new House (door); 1 class House{

30 public class WarmUp{ public static void main(String[] args) { Door doornew Door (100.00); House cheapHouse = new House (door); 1 class House{

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.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

In the given code snippets there are a couple of issues related to variable assignment that need to ... View full answer

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 Programming Questions!