Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

What does this class do in Java?

Posted on 2007-03-28
7
177 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 300 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 300 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
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.

 
LVL 10

Assisted Solution

by:Jaax
Jaax earned 100 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 300 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 100 total points
ID: 18814118
0
 
LVL 37

Expert Comment

by:zzynx
ID: 18814604
Thanx 4 axxepting
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
xampp tool 12 56
servlet example 11 49
hibernate insert example 13 34
Java: The Public Class Main 4 30
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This video teaches viewers about errors in exception handling.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

809 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