Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


how can u handle run time exception in java? explain with
brief explanation with examples?

Answers were Sorted based on User's Feedback



how can u handle run time exception in java? explain with brief explanation with examples?..

Answer / pavithra

public class ExceptionalClass {
public void method1() throws CheckedException {
// ... some code
throw new CheckedException( "something bad
happened" );
}
public void method2( String arg ) {
if( arg == null ) {
throw new NullPointerException( "arg passed to
method2 is null" );
}
}
public void method3() throws CheckedException {
method1();
}
}

Contrast method1() with method2(). When you
make a call to method2(), you don't have to do so within a
try/catch block. Since you do not have to catch the
exception, the exception is said to be unchecked; it is a
runtime exception. A method that throws a runtime exception
need not declare the exception in its signature.

Is This Answer Correct ?    9 Yes 3 No

how can u handle run time exception in java? explain with brief explanation with examples?..

Answer / pavithra

Runtime exceptions represent problems that are detected by
the runtime system. This includes arithmetic exceptions
(such as when dividing by zero), pointer exceptions (such
as trying to access an object through a null reference),
and indexing exceptions (such as attempting to access an
array element through an index that is too large or too
small).

Runtime exceptions can occur anywhere in a program and in a
typical program can be very numerous. Typically, the cost
of checking for runtime exceptions exceeds the benefit of
catching or specifying them. Thus the compiler does not
require that you catch or specify runtime exceptions,
although you can.

Is This Answer Correct ?    5 Yes 8 No

Post New Answer

More Core Java Interview Questions

How does remove work in java?

0 Answers  


What's the default access specifier for variables and methods of a class?

0 Answers  


What is backdrop?

0 Answers   Atos Origin,


What are the important features of Java 8 release?

0 Answers  


Hi Friends.. can any one provide the real time example for methodoverloading and methodoverriding .........

2 Answers   Honeywell,


What is the difference between compare and compareto in java?

0 Answers  


Can an interface have a class?

0 Answers  


Is a case study a method or methodology?

0 Answers  


What is difference between final and immutable?

0 Answers  


Why packages are used?

5 Answers  


How strings are created in java?

0 Answers  


Can you call a private data from an inner class?

6 Answers  


Categories