Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


samar
custom exception
1 Answer(s)      4 years and 2 months ago
Posted in : Java Interview Questions


What is user defined exception?

Advertisement
View Answers

October 29, 2010 at 5:23 PM


Hi,

Here is the answer.

User defined exceptions are those exceptions which an application provider or an API provider defines by subclassing java.lang.Throwable class.

This example help you-

 class MyException extends Exception {
    int a;

    MyException(int b) {
        a = b;
    }

    public String toString() {
        return ("Exception Number =  " + a);
    }
}

 public class JavaException {
    public static void main(String args[]) {
        try {
            throw new MyException(24);
            // throw is used to create a new exception and throw it.
        } catch (MyException e) {
            System.out.println(e);
        }
    }

}

For more detail go to the link-

http://www.roseindia.net/java/java-exception/user-defined-exception.shtml

Thanks.



Related Tutorials/Questions & Answers:
custom exception
custom exception  What is user defined exception
custom exception
custom exception  Explain the process of creating custom exception and handling it.   Please visit the following link: Making custom exception
Advertisements
Exception Handling : Custom Exception
Exception Handling : Custom Exception In this tutorial, we will discuss about the Custom Exceptions(user defined exceptions). Custom Exception : Custom.... These custom exception can be thrown using the keyword 'throw'
Custom Exceptions
error.  Custom Exception inherits the properties from the Exception class.... In the example given below we have declared our own Custom Exception which...; <TITLE>Custom Exception in jsp</TITLE> </HEAD>
exception
exception  wHEN RUNTIME EXCEPTION CLASS IS SUB OF EXCEPTION CLASS HOW CAN'T HANDLE UNCHECKED EXCEPTION
exception
exception  chek in and check out exception in java   Please visit the following link: Checked and Unchecked Exception
exception
arguments are not equalto two,throw a user defined exception "invalid parameter exception" ,otherwise display the two parameters.   Here is an example... is not equal to two then invalid parameter exception is thrown ,otherwise display the two
exception
exception  what is the use of catch block even though we have predefined exception object
exception
defined checked exception ââ?¬Å?InvalidCharcterFoundExceptionââ?¬Â? and creater a block of codes that will handle the exception
exception
exception  example for numberformat exception   Hi Friend, Try the following code: class NumberFormatExceptionEx{ public static void...); } catch(Exception e){ System.out.println(e
Exception
Exception  whis is the Arithmetic Exception in java? or define Arithmetic Exception with exp?   Arithmetic Exception occurs, when you divide a number by zero. Example public class TryCatch { public static void main
Exception
Exception  public class FooException extends Exception { public..."); } public void calculate() throws FooException, Exception { try { int.... ex.printStackTrace(); System.exit(1); } catch(Exception ex
Custom skin
Custom skin  Hi..... How can I make a custom skin for focusSkin property of component? please give me an example for that so i can clearly understand..... Thanks   Ans: you need to set the focusSkin using custon
Exception
Exception   I was creating a table dynamically but it shows exception i.e shown down Suplier created0 Suplier created0 Suplier created0 Product created0 Product created0 Product created0 Product created0 could not fetch initial
exception
user defined unchecked exception  can we create user defined unchecked exceptions? if so what is the exact use of it in real time?   Please visit the following links: http://www.roseindia.net/java/java-exception/user
exception
exception  Identify the reason for SQLException exception, which is encountered when the developer tries to run the following code snippet to insert..."); ps.executeUpdate(); } catch(Exception e
custom validation
custom validation  there are fields.if we fill in first field as 1.then next field only allow to fill a,b,c,d.other letters cannot enter.if enter send error.i used this method. frmvalidator.addValidation
what is custom validation in struts
what is custom validation in struts  what is custom validatons in struts
Custom Website Design,Custom Web Designing,Custom Website Designing
Custom Website Design Custom Website Design Custom website designs means... Technologies Pvt Ltd is specialized company in Custom website designing. Why Custom Website Designing? The Custom Web Designing means the designing
jsf custom tooltip
jsf custom tooltip  I wants to know that is it possible to add a tooltip to the Custom JSF
Custom Cell View UITableview
Custom Cell View UITableview  How can i get two custom cell view in UITableView
HTML custom buttons
HTML custom buttons  How can I make a form with custom buttons
custom uibutton programmatically
custom uibutton programmatically  Hi, How to create custom uibutton programmatically? Thanks   Hi, Please see the thread UIButton custom programmatically. Thanks
custom tags - JSP-Servlet
custom tags  Hai this is jagadhish. Iam learning java custom tags.Before doing these programs which jar file we have to add in the classpath..., For solving the problem visit to : http://www.roseindia.net/jsp/custom
Custom Form Validation - PHP
Custom Form Validation  Which is the best way or where should I implement the custom validation rules such as ? using number, capital letters and symbols to secure the password
JSP-Custom tags
JSP-Custom tags  First page (HTML) should display a form to enter marks for 3 subjects. On submit, the invoked jsp with custom tags should compute the average of 3 subjects
Custom Business Software Development
Custom Business Software Development  What is a Custom Business Software Development?   Custom Business Software Development Any software..., large and medium Business Softwares. And a Custom Business Software
custom navigation bar in iphone
custom navigation bar in iphone  How can i create a custom navigation bar in iPhone application? I wanted to add UIBarButton items as well as Search bar on the UINavigation controller ... please tell me if i need to create
Custom Validations - Struts
Custom Validations  Hi, I am trying to do the custom validations in struts 1.1.That is how can we plug in our own custom validations into Validator ? Can anybody tell me how to do this with a sample example. Thanks
UIButton custom programmatically
UIButton custom programmatically  Hi, Please tell me how I can create custom UIButton programmatically? Tell me the best code for uibutton custom programmatically. Thanks   Hi, Here is the code example of crating
Custom tags in Jetty
Custom tags in Jetty  Any one knows about Jetty 6.1.22 Server Supported TLD File Version????If so could you please provide an sample TLD file
 

 

 

DMCA.com