aspose file tools*
The moose likes Java in General and the fly likes Exception problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Exception problem" Watch "Exception problem" New topic
Author

Exception problem

Rippon Jalali
Greenhorn

Joined: Aug 25, 2006
Posts: 23
Can anybody tell me why this program is giving compiler error.
In my opinion it should run fine as first Test11() constructior will b called the implicit call to super which is valid too.

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

Joined: Aug 05, 2005
Posts: 3153
    
  10
The only error I get is that the Test11 constructor that takes an int should be declared to throw an exception, which is what I would expect as the parent class constructor that it implicitly calls is declared to throw an Exception.
[ January 05, 2007: Message edited by: Joanne Neal ]

Joanne
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

Hi,

Welcome to JavaRanch!

We have a strict policy on display names, which must be a real first and last name with a space between.

Please go here and fix your display name up, pronto. Thanks, pardner!


[Jess in Action][AskingGoodQuestions]
Rippon Jalali
Greenhorn

Joined: Aug 25, 2006
Posts: 23
Thank you Neal But i am not using that constructor any where in my code .So what is the need of that..
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18101
    
  39

Originally posted by Rippon Jalali:
Thank you Neal But i am not using that constructor any where in my code .So what is the need of that..


The compiler is *not* that smart. If you have a constructor that have a compile error, it is an error condition. It will not allow you to have errors in it just because you are not using it.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Rippon Jalali
Greenhorn

Joined: Aug 25, 2006
Posts: 23
i got it. thanks henry and Neal
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception problem
 
Similar Threads
Generics - > Class Type Parameter Question
Which of the Following is True?
difference between redefining and overridding
Overloading vs Overriding
compile error -- Exception