answersLogoWhite

0


Best Answer

The important keywords used in Java with respect to Exception Handling are:

a. Throw - The "throw" keyword is used to throw exceptions from inside a method

b. Throws - The "throws" keyword is used to signify the fact that the code contents within the current method may be throwing an exception and the calling method must handle them appropriately

User Avatar

Wiki User

10y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

throws

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What keyword are used in java for exception handling?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Why use catch keyword in java?

no, because catch is used to handle exceptions which are generated from try block


When should we use exception handling in java?

Exception handling should be used in Java in all cases where you as a programmer suspect that your code might throw some exceptions or create errors that might look ugly when a user is using the application. In such cases you use exception handling to catch and handle the exception and exit gracefully. You use the try - catch block in Java for exception handling.


What is the use of try in java?

The try keyword is used in Java to handle problematic situations that are commonly known as "Exceptions" The try keyword is used in conjunction with the catch keyword. If any exception is thrown by code inside the try block, they will be caught and handled by the catch block. Ex: try { ... ... } catch (Exception e){ ... }


What is throw keyword in java?

The throw keyword is used from within a method to "throw" an exception to the calling method. In order to throw an exception, the method signature must indicate that it will throw an exception. For example: public void foo() throws Exception { } When you want to actually throw the exception, you can do it a few different ways: throw new Exception("Exception message"); or from within a catch block ( catch(Exception ex) ): throw ex;


Why should throw keyword is used in java?

Use it when you are implementing something that says it throws a certain exception when a certain condition is met.


Define a catch block?

A Catch block is part of the exception handling mechanism in Java. It is used along with the try block. Ex: try { ... } catch (Exception e) { ... } The catch block is used to catch & handle the exception that gets thrown in the try block.


How java use extern key word which is used in C plus plus?

No extern keyword in Java.


Describe how throw and throws clause differ when implementing exception handling in java?

The throw keyword is used to throw an exception that may be generated in a code block. Ex: if (some condition){ throw new CannotProcessFileException("InvalidFile"); } The throws keyword is used in method signatures to signify the fact that, this method would be throwing exceptions of the type specified if the code in the method happens to generate one. Ex: public String getNameFromDB(int id) throws SQLException {


How exception handling mechanism can be used for debugging a program in java?

Trapping and handling of runtime errors is one of the most crucial taska ahead of any programmer. AS A DEVELOPER, YOU SOMETIMES SEEM TO SPEND MORE TIME CHECKING FOR ERRORS AND HANDLING THEM THEN YOU DO ON THE CORE LOGIC OF THE ACTUAL PROGRAM.


What is the use of throw statement?

throws keyword/statement is basically used to handle exception in java. throws keyword is used to handle "unchecked exceptions". Example: public void enterdata()throws IOException { BufferedReader inp=new BufferedReader(new InputStreamReader(System.in)); int i=Integer.parseInt(inp.readLine()); } Now after the enterdata function we have used throws keyword because the"readLine" method throws an unchecked exception ie., IOException during user input which cannot be handled by try catch block.


Which package in java is treated as default package?

java.lang defines the core Java language, without which all of Java would fail to operate. It is therefore the default package that must be used with every program that will run Java, as it contains all of the logic necessary for exception handling, threads, classes that represent primitives (and their associated logic), and so on.


Is super keyword is anologous to this keyword in java?

No. The keyword super is used to refer to the parent class instance while the keyword this is used to refer to the current class instance. You need to learn about Inheritance and Object creation using constructors to learn more about these keywords and their use