Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By DarrylBurke

Thread: Java Exception Handling regarding Constructor

  1. #1
    DeepakDev is offline Member
    Join Date
    Mar 2013
    Posts
    1
    Rep Power
    0

    Question Java Exception Handling regarding Constructor

    Hi Everybody

    In the below code ...If i remove constructor Test11(int i) or change it to Test11(int i) throws Exception then it compile and run.Can anybody clarify why compiler ask to include throws clause in constructor Test11(int i)...though I am explicitly calling Test11() by .... Test11 t = new Test11();


    public class Test11 extends A
    {
    Test11()throws Exception{
    System.out.println("Test10 Class");
    }
    Test11(int i)
    {
    System.out.println("Test10 Classdfdfdfdff");
    }
    public static void main(String args[]) throws Exception{

    Test11 t = new Test11();
    }
    }
    class A
    {
    A() throws Exception{
    System.out.println("A Class");
    }
    }


    Why does it do so when it does not explicitly or implicity get the Exception

    Thanks
    DeepakDev

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Java Exception Handling regarding Constructor

    Moved from a staff-only section.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Java Exception Handling regarding Constructor

    Cross posted and didn't have the courtesy to reply to the second response there before asking the same question here:
    Java Exception Handling regarding Constructor (Java in General forum at JavaRanch)

    db
    PhHein likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default Re: Java Exception Handling regarding Constructor

    Thanks for the heads up, Darryl.
    ignoreList++
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

Similar Threads

  1. exception handling
    By Elaforestis in forum New To Java
    Replies: 1
    Last Post: 01-29-2013, 04:37 AM
  2. Exception Handling
    By Bicentric in forum New To Java
    Replies: 1
    Last Post: 07-22-2012, 09:37 PM
  3. Exception handling
    By ExX in forum New To Java
    Replies: 6
    Last Post: 03-12-2012, 11:48 AM
  4. Replies: 2
    Last Post: 03-14-2011, 11:34 AM
  5. exception handling in java
    By koushikG in forum New To Java
    Replies: 1
    Last Post: 12-04-2010, 12:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •