EBK JAVA PROGRAMMING
8th Edition
ISBN: 9781305480537
Author: FARRELL
Publisher: CENGAGE LEARNING - CONSIGNMENT
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 12, Problem 1RQ
Program Description Answer
In object-oriented
Hence, the correct answer is option “B”.
Expert Solution & Answer
Explanation of Solution
Exception:
- In Java, the exception is an object used to signal the unexpected error occurred during a program execution.
- Exception is the error, which arises at run time and such errors can be handled in Java by exception handling.
- The exception handling allows a method to throw an error to its caller and allowing the caller to manage that error.
- The called method itself must manage the error or end the program without this exception handling. But the called method does not know when error occurs.
- The library method helps to find the error, but only caller method knows how to handle that errors.
Want to see more full solutions like this?
Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
This programming assignment involves learning about some of the common exceptions that occur in Java programs. Consider the following exception types:
NumberFormatException
ArrayIndexOutOfBoundsException
FileNotFoundException
IllegalArgumentException
Research what each exception type means and the conditions under which each occurs (i.e., is thrown). Write programs that demonstrate each type of exception being thrown (one program per exception). Write 3 procedural programs and 1 Object Oriented Program. They can be very simple but make them up.
You should write your code so that each exception type is forced to occur. Name your programs so that we can determine which exception you are using in the code. Example FileNotFoundException FileExists.java or something creative.
Then, write a program that catches each type of thrown exception and display an error message indicating some of the details as to what that exception is.
Write one program per type of exception. They can be…
We are asked to add an exception to the game. Please see below.
For this part of the assignment you can start by creating your own exception in a file named NumberGuesserIllegalStateException.java, with this code:
public class NumberGuesserIllegalStateException extends Exception {
public NumberGuesserIllegalStateException(String errorMessage) {
super(errorMessage);
}
}
Next modify your code so that the higher and lower methods of both the NumberGuesser and RandomNumberGuesser should throw the exception if there are no more remaining numbers to guess. You might be able to achieve this by adding the logic to your NumberGuesser and letting RandomNumberGuesser inherit the behavior. Or you might need to add the logic to both classes. It will depend on your implementation.
Finally add a try-catch block to your number guessing game so that the user is notified if the user cheats.
I need a Java program that utilizes a user-defined exception named LowBalanceException. The program can be simple but I want the exception to be thrown if their account balance goes below a minimum threshold such as $50.
Please and thank you kind stranger
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- I know the gudelines says to solve 3 Multiple Choice at a time but as I do not have any more questions please solve one more multiple choice so I don't have to use another question. 7.) What exception type does the following program throw? public class Test { public static void main(String[] args) { String s = "abc"; System.out.println(s.charAt(3)); } } a. ArithmeticException b. ArrayIndexOutOfBoundsException c. StringIndexOutOfBoundsException d. ClassCastException e. No exception 8.) A method must declare to throw ________. a. unchecked exceptions b. checked exceptions c. Error d. RuntimeException 9.) Which class contains the method for checking whether a file exists? a. File b. PrintWriter c. Scanner d. System 10.) Which method can be used to create an input object for file temp.txt? a. new Scanner("temp.txt") b.new Scanner(temp.txt) c. new Scanner(new File("temp.txt")) d. new Scanner(File("temp.txt"))arrow_forwardDesign and implement a customized exception in a real scenario a) Description of the scenario that you decided b) Design the model of your work using Flowchart c) Implement your design model d) Your output results (clear screenshot) [N.B: I need answer every single part .please urgently solve these problem]arrow_forwardI have the following code; a lot of details are unclear; this is a Java code; please draw the CFG (Control Flow Graph); it should look something like this: this is the source code: private void function() { try{ var1 = something; var2 = something; var2.function2(1,param1. param2);var2.function2(2, param1. param2); var3 = something; if (var3 > 0) { statements; } else { statements;} }//end of the try catch (exception) {print; } // end of catch }//end of the functionarrow_forward
- This is a java program read the steps carefully please : Design and implement a customized exception in a real scenario Your assignment must contain with the proper cover page:1) Description of the scenario that you decided2) Design the model of your work using Flowchart3) Implement your design model4) Your output results (clear screenshot).arrow_forwardint xy=3;if (xy==2) xy=0;else if (xy==3); xy++;else xy=xy+2;What is the value of xy? Select one: a. invalid b. 2 c. 4 d. 0 It is the first company where the drag and drop programming interface was developed. Select one: a. Oracle Corporaion b. Tripod c. IBM d. MIcrosoft OOP is the acronym for Select one: a. Object Oriented Programming b. Oriented Object Programming c. Objected Oriented Program d. Objected Orienting Programarrow_forwardHow do I fix the error Java? Error ---------- Movie.toString() returns: Movie: [ Minutes 142 | Movie Name:The Shawshank Redemption | not kid friendly | Number of Cast Members: 3 | Cast Members: ] instead of: Movie: [ Minutes 142 | Movie Name: The Shawshank Redemption | not kid friendly | Number of Cast Members: 3 | Cast Members: Tim Robins, Morgan Freeman, Bob Guton ] without bringing this error Error ---------- Exception occurred while calling Movie.toString() Code: import java.util.*; import java.util.Arrays; public class Movie { private String movieName; private int numMinutes; private boolean isKidFriendly; private int numCastMembers; private String[] castMembers; // default constructor public Movie() { this.movieName = "Flick"; this.numMinutes = 0; this.isKidFriendly = false; this.numCastMembers = 0; this.castMembers = new String[10]; } // overloaded parameterized constructor public Movie(String movieName, int numMinutes, boolean isKidFriendly, String[] castMembers)…arrow_forward
- The calculator should have the features and functions similar to the calculator found in Windows OS. Given below is the interface of the calculator and you should also design a similar user interfaceAssignment Requirements Develop the complete application using Java. Your calculator should have mandatory functions such as Add, Subtract, Multiply and Divide. Ensure your program can handle exceptions.Note: You only need to include buttons for the numbers, addition, subtraction, multiplication, division, backspace, equal, cancel, and negation. Other buttons are not needed. The program must be well documented with proper comments where needed for readability and to explain relevant coding.arrow_forwardCreate a program named ConsoleAppException that divide 2 numbers and display the result. Ensure that your program implements the exception handling. Again, the program should have a constructor that initialize the result to zero. The calculation should happen in a method named Division() that takes two parameters (num1 and num2). The main method is only used to call the division() method . Use 25 for num1 and 0 for num2.arrow_forwardUsing python, make a program: 1. Create a calculator app 2. The user will choose between the 4 math operations (Add, Subtract, Multiply and Divide) 3. The application will ask for 2 numbers 4. Display the result 5. The application will ask again if the user wants to try again 6. Use the appropriate Exception (ex: Invalid input such as text and zero division)arrow_forward
- The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. You also will use a file named DebugEmployeeIDException.java with the DebugTwelve4.java file. // An employee ID can't be more than 999 // Keep executing until user enters four valid employee IDs // This program throws a FixDebugEmployeeIDException import java.util.*; public class DebugTwelve4 { public static void main(String[] args) { Scanner input = new Scanner(System.in); String inStr, outString = ""; final int MAX = 999; int[] emps = new int[4]; for(int x = 0; x < emps.length; ++x) { System.out.println("Enter employee ID number"); inStr = input.next(); try { emps[x] = Integer.parseInt(inStr); if(emps[x] > MAX) { throw(new…arrow_forwardIn every program data must be validated before the program can proceed with further processing and storage of the input data. As a Windows developer for a data analysis company, you are tasked to develop an application using Windows form / Windows Presentation Foundation (WPF) named mileage efficiency. Your interface should look as shown below.You should include the following in your program1. Exception handling should be used to prevent users from entering invalid input (text, character...) (try, catch and final)2. All exception messages should be display using a message box and save in a text file called Exceptionfile.txt3. All result (miles divided by gallon) should be save in a file called MilesperGallon.txt. The result should be saved once the calculate button is pressed 4. Meaning your program will have two separate text files one to record all exception thrown – message and the other to record all calculation and the date and time the operation occurred Run the project. Enter…arrow_forwardIn every program data must be validated before the program can proceed with further processing and storage of the input data. As a Windows developer for a data analysis company, you are tasked to develop an application using Windows form / Windows Presentation Foundation (WPF) named mileage efficiency. Your interface should look as shown below. The program should have exception handling in as well. You should include the following in your program 1. Exception handling should be used to prevent users from entering invalid input (text, character...) (try, catch and final) 2. All exception messages should be display using a message box and save in a text file called Exceptionfile.txt 3. All result (miles divided by gallon) should be save in a file called MilesperGallon.txt. The result should be saved once the calculate button is pressed 4. Meaning your program will have two separate text files one to record all exception thrown – message and the other to record all calculation…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT