Results 1 to 2 of 2

Thread: java forum

  1. #1
    Junior Member
    Join Date
    Feb 2008
    Answers
    3

    Lightbulb java forum

    hi firiends what is difference between throw and throws keywords in java exception handling


  2. #2
    Junior Member
    Join Date
    Feb 2008
    Answers
    6

    Re: java forum

    Hi kuklkarni,

    Throws :- it is used to specify method level excetpion,to specify some statements in side a method level, when we are calling this type of methods we must handle the exceptions thrown by statements in the method.
    eg :- public class ThrowEeg{
    void m1() throws Exception
    {
    sop("");
    a= a/0;
    sop(a);//this line throws Exception.

    sop(""); //this line dose n't excute
    }
    public static void main(String arg[])
    {
    ThrowEeg thre = new ThrowEeg();

    try{ //here we call the try statement.

    thre.m1();//method calling here.

    }
    catch(Exception e){
    sop(e);
    }
    }

    Throw :- it is generally use with user defined exceptions.to manually throw an exception use this key word.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact