?
Solved

What does this class do in Java?

Posted on 2007-03-28
7
Medium Priority
?
186 Views
Last Modified: 2010-03-31
What does this class do in Java? What is an exception in Java?
package org.muos.management.managementSupport;

/**
 *      The wrapper exeption which wrap the underline exceptions.
 *
 */
public class ManagementSupportException extends Exception {
      private String message;

      public ManagementSupportException(String message) {
            this.message = message;
      }
}
0
Comment
Question by:yankeebushsoftware
7 Comments
 
LVL 8

Accepted Solution

by:
mnrz earned 1200 total points
ID: 18813943
it does nothing, it is just an Exception and can be thrown by code like this:

throw new ManagementSupportException();
0
 
LVL 8

Assisted Solution

by:mnrz
mnrz earned 1200 total points
ID: 18813947
Although you may use "throw new Exception()" but this is much clear and better to categorize your exceptions
0
 

Author Comment

by:yankeebushsoftware
ID: 18813950
What's an exception?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Assisted Solution

by:Jaax
Jaax earned 400 total points
ID: 18813966
This class serves as your application specific exception extended from the java's Exception class
By using a customized exception class for your application, you can add more features to the class whilst benefitting from those already present in the exception class. This reduces coding and maintainability - the benefits of inheritance.
It is like buying a new car and modifying it to a certain extent to suit your taste and style while maintaing the engine and transimission in tact.

The Exception class serves to indicate any abnormality the program encounters during the course of its execution. By throwing an exception the cause and nature of the problem is reported to the calling methods. It helps to diagnose the problem. Different kinds of exception  can point to different kinds of exceptional conditions or abnormalities.
0
 
LVL 8

Assisted Solution

by:mnrz
mnrz earned 1200 total points
ID: 18813987
consider this code:

int i = 0;
int j = 10;

j = j / i; //(1)

(1) this line throws an exception (error) because no number can divided into 0.

the thrown exception has a message like "Divide by Zero"

so you can catch this error by a try/catch block and display the message of error:

try{
    j = j / i;
}catch(Exception x){
    System.out.println(x.getMessage());
}

but you can define a new exception , say, DivideByZeroException like the code you mentioned

now:

try{
    j = j / i;
}catch(DivideByZeroException x){
    System.out.println(x.getMessage());
}


this is much better than former code because any programmer by a quick look at the code will understand what error might happen during this code.
0
 
LVL 37

Assisted Solution

by:zzynx
zzynx earned 400 total points
ID: 18814118
0
 
LVL 37

Expert Comment

by:zzynx
ID: 18814604
Thanx 4 axxepting
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question