Ravi Chandanani

Greenhorn
+ Follow
since May 31, 2011
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ravi Chandanani

Hello all,



This example generates output : Result :-9.0


What is the reason for that conditional operator (test ? 9 : 9.45) to print 9.0 instead of 9 ?

Thanks in advance,
Ravi chandanani
Hello matej spac ,

Yes thats true,I am now clear about "broader and nerrow" concept,

Thanks you so much for quick reply,
Ravi Chandanani
Hi matej spac,


Thanks for quick reply,

My interpretation from following statement,
"The overriding method must NOT throw checked exceptions that are new or broader than those declared by the overridden method"
is if class C extends class B,class B extends class A,class A extend Exception.

The class C is broader than class B and class B is broader than class A and class A is broader than class Exception.

If i am correct here,then class SubException would be broader class than class Exception.

class SubException extends Exception { }
public class CC { void doStuff() throws SubException { } }
class CC3 extends CC { void doStuff() throws Exception { } }




Please correct me if i am miss understanding anything here,

Thanks,
Ravi Chandanani

Hello All,

I have one query regarding following example,




1:import java.io.FileNotFoundException;
2:import java.io.IOException;

3:class SubException extends Exception { }
4:class SubSubException extends SubException { }

5:public class CC { void doStuff() throws SubException { } }

6:class CC2 extends CC { void doStuff() throws SubSubException { } }

7:class CC3 extends CC { void doStuff() throws Exception { } }

8:class CC4 extends CC { void doStuff(int x) throws Exception { } }

9:class CC5 extends CC { void doStuff() { } }

10:class CC6 extends CC { void doStuff() throws FileNotFoundException { } }



here if we compile above example,there will be compilation error at line 7 & 10.

according to the rule "An overriding method cannot throw a broader exception than the method it's
overriding."


For line number 8 the exception thrown is "Exception" it self,which is not broader than class SubException,as class SubException already extending the class Exception.

can anyone explain what is the reason for compilation error at line 7 & 10.


Thanks in advance,
Ravi