ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
how can u handle run time exception in java? explain with 
brief explanation with examples?
 Question Submitted By :: Jawahar
I also faced this Question!!     Rank Answer Posted By  
 
  Re: how can u handle run time exception in java? explain with brief explanation with examples?
Answer
# 1
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 ?    4 Yes 0 No
Pavithra
 
  Re: how can u handle run time exception in java? explain with brief explanation with examples?
Answer
# 2
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 ?    2 Yes 3 No
Pavithra
 
 
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
Catch(Exception e){ } in that what is Exception and purpose of that in that place exactly?  3
Explain the difference between getAppletInfo and getParameterInfo?  1
C and C++ has constructors and distructors, why does Java does not have distructors? T3-Softwares1
What is the argument type of main() method?  2
I/O blocking means?  1
what is mean by String and StringBuffer? What is mean by Methooverriding and Overloading? Satyam2
what is Inheritense Tech-Mahindra1
What is unicode?  1
What is casting?  3
What are the names of interfaces that doesn't consists of method/s ?  3
how to handle exceptions in core applications? CSS2
What are wrapper classes? Noah-Solutions6
What is the superclass of exception?  2
In Serialization, whether you will use Static variables? HCL2
To obtain design information about an object, which class in used?  1
How many bits are used to represent unicodde,ASCII,UTF-16 and UTF-8 characters?  2
How to avoid the runtime exception ?  2
What is difference between abstract class & final class  5
Hi Friends, I am new to java. Can u explain about thread concept.How i know one thread is locked, and how can i force or acquire another thread for lock . Finally how to know thread is released from lock. Explain types of lock(like method level and block level) in thread.  1
what is difference between prepare stetement and callable starement with example? CMC1
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com