Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

Throw Keyword in Core Java

Ads

 
 

Share on Google+Share on Google+

murali
Throw Keyword in Core Java
2 Answer(s)      9 years ago
Posted in : Java Interview Questions

Why to use Throw Keyword in Core Java?

Ads
View Answers

February 25, 2008 at 5:58 PM


throw keyword. it is used to user rethrow Exception to caller.its at a time only one exception we can throw.But throws key word is method signature level it will be send multible Exception to the caller
example:

throws:

void meth() throws IOException,ServletException
{
}

throw:

void meth()
{
new throw("user Exception message");
}


February 26, 2008 at 12:09 PM


Difference between throw and throws

throw is used to throw an exception manually, where as throws is used for checked exceptions, to re-intimate the compiler that we have handled the exception. So throws is to be used at the time of defining a method and also at the time of calling that function, which rises an checked exception it gives the compile time error. Use throws to define our own exception or handle the exception the exception by try-catch, otherwise it gives the compile time error.

Ads









Related Tutorials/Questions & Answers:
Using throw keyword in exception handling in Core Java
Description: Core Java Throw Function is used for throwing the exception. The throw keyword tells the compiler that it will be handled by calling a method... exception need to be thrown from the calling method. Code for Java Throw Exception
throw Java Keyword
throw Java Keyword       "throw " is a keyword defined in the java programming... to a compiler in java programming language likewise the throw keyword indicates
Advertisements
The throw keyword example in java
)){ throw new MyMadeException(); } System.out.println ("Third"
Java throw and throws Keyword Example
Java throw and throws Keyword Example In this section we will read about how to throw the caught exception using throw and throws keywords in Java. throws and throw keywords in Java are used in the Java Exceptions. Keyword throw
Java throw and throws
Java throw and throws  What is the difference between throw and throws
Java throw ,throws
Java throw ,throws  What is the difference between throw and throws
Using throw in java method
Using throw in java method  using throw with method implies what
Difference between throw and throws in java.
Difference between throw and throws in java. Throws and throw both are keywords in java, used for handling the exception.  When a method is not able to handle the checked exception, it should declared with throws keyword
Java keyword
Java keyword  Is sizeof a keyword
Java ?throw? Keyword
Java ?throw? Keyword      ... an exception, the developers use the throw keyword with an object reference...; www.roseindia.net/java/exceptions/how-to-throw-exceptions.shtml  
throws Java Keyword
in java programming language likewise the throw keyword indicates the following... throws Java Keyword       throws " is a keyword defined in the java programming language. Keywords
this java keyword
this java keyword       "this" is a keyword defined in the java programming language. Keywords... in java programming language likewise the this keyword indicates the following
transient keyword - Java Beginners
transient keyword  what is transient keyword in java.? plz explain with example
try Java Keyword
try Java Keyword       The try is a keyword defined in the java programming language. Keywords... : -- The try keyword in java programming language is used to wrap the code in a block
"compilation error " & "throw an exception" - Java Beginners
"compilation error " & "throw an exception"  Hello. I have...=sql2.executeUpdate("Select * From Publishers"); a. Will throw an exception b... not a?  Hi friend, throw a exception "Can not issue SELECT via
while Java Keyword
while Java Keyword       The while is a keyword defined in the java programming language... to a compiler in java programming language likewise the while keyword indicates
volatile Java Keyword
volatile Java Keyword       The volatile is a keyword defined in the java programming language... to a compiler in java programming language likewise the volatile keyword indicates
true Java Keyword
true Java Keyword       The true is a keyword defined in the java programming language. Keywords... in java programming language likewise the true keyword indicates the following
void Java Keyword
void Java Keyword       The void is a keyword defined in the java programming language. Keywords... in java programming language likewise the void keyword indicates the following
transient Java Keyword
transient Java Keyword       The transient is a keyword defined in the java programming language... to a compiler in java programming language likewise the transient keyword indicates
super Java Keyword
super Java Keyword       The super is a keyword defined in the java programming language... to a compiler in java programming language likewise the super keyword indicates
The new keyword in java
The new keyword in java In this section you will learn about new keyword in java. The new keyword is used to create a instance of a class. The new keyword... declaration. Creating  an object by new keyword this is nothing
Java Throw Built-in Exception
will demonstrate you about how to use throw keyword in Java to throw the exception...Java Throw Built-in Exception In this section we are discussing about throwing of built-in exceptions in Java. In Java throw and throws keywords are used
Return Java Keyword
Return Java Keyword       The return is a keyword defined in the java programming language. Keywords... in java programming language likewise the return keyword indicates the following
synchronized Java Keyword
synchronized Java Keyword       The synchronized is a keyword defined in the java programming... relevant to a compiler in java programming language likewise the synchronized keyword
Private Java Keyword
Private Java Keyword       private is a keyword defined in the java programming language. Keywords... in java programming language likewise the private keyword indicates the following
Public Java Keyword
Public Java Keyword       public is a keyword defined in the java programming language. Keywords are basically reserved words which have specific meaning relevant to a compiler in java
static Java Keyword
static Java Keyword       The static is a keyword defined in the java programming language. Keywords... in java programming language likewise the static keyword indicates the following
Core Java - Java Interview Questions
Throw Keyword in Core Java  Why to use Throw Keyword in Core Java?  throw keyword. it is used to user rethrow Exception to caller.its...() throws IOException,ServletException{}throw:void meth(){new throw("user
Protected Java Keyword
Protected Java Keyword       protected is a keyword defined in the java programming language. Keywords... in java programming language likewise the protected keyword indicates
short Java Keyword
short Java Keyword       The short is a keyword defined in the java programming language. Keywords... in java programming language likewise the short keyword indicates the following