Question: Problem 3 NullPointerException. We will be using the Flight class we created on day 3 in practice 1. Update the light class in the com.day3.practice1

 Problem 3 NullPointerException. We will be using the Flight class we
created on day 3 in practice 1. Update the light class in

Problem 3 NullPointerException. We will be using the Flight class we created on day 3 in practice 1. Update the light class in the com.day3.practice1 package and add a setPrice method. Update the exceptionDema class. Create a method called updateFlightPrice that will pass in a Flight and a price. The method will retum nothing. The method will use the setPrice method to update the price. Update the main method. Comment out the previous call to get Double and the surrounding try/catch. Create a flight object and set it to null. Call the set Price method. If the setPrice method throws a NullPointerException, catch it and price the stacktrace. Class outline: Flight flightld: int airline : String - flightNo: String source: String a destination : String price: double Flight(int, String, String, String, String, double) .getFlightld()int getAirline(): String getFlightNo0 : String getSource(): String .getDestination String getPrice0.double SetPrice(double): void ..toString(): String G. ExceptionDemo main(Stringtt ) void updateArray(int), int, int) : void getDoublel). double updateFlightPricelFlight double) void Problem 4 ClassCastException. Use the RollerBot class from Day 3 practice 2. Update the exceptionDemg class. Create a method class called moveByWalking that passes in a Robot object and a distance (double). The method will return nothing. The method will cast the Robot as a WalkerBot and then call the move method, passing in the distance. Update the main method. Comment out the previous call to updateFlightPrice and its surrounding try/catch. Create a new RollerBot. Pass that object into the moveByWalking method with a distance of Surround the call by a try/catch for ClassCastException. Have the catch print the stacktrace. Class outline: ExceptionDemo main(String[]} void updateArray(int), int, int) : void getDouble double updateFlightPrice(Flight, double) void moveByWalking(Robot, double) void

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!