• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

overriding concept?

 
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


here i feel the answer to be only a ..
but its not...
i feel d,e are wrong as the overriding method should not thrown any new checked exceptions and b,c can be eliminated based on overriding principle(they should have same argument type and return type)


why is it so??

thanks
sri..
 
Ranch Hand
Posts: 340
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I think answer is A,B,D,E

a) public static void main( String args[] ){} ///ofcourse valid
b) float methodTwo(){}//methodTwo is being overloaded and not overridden
c) long methodOne( int c, long d ){}//invalide return type is different
d) int methodOne( int c, long d ) throws ArithmeticException{}//valid throws unchecked exceptions
e) int methodOne( int c, long d ) throws FileNotFoundException{}//valid throws unchecked exceptions


Hope it helps
[ October 11, 2005: Message edited by: Sandeep Chhabra ]
 
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


e) int methodOne( int c, long d ) throws FileNotFoundException{}//valid throws unchecked exceptions



FileNotFoundException is a checked exception. It's valid because FileNotFoundException extends IOException.
 
Sandeep Chhabra
Ranch Hand
Posts: 340
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops ...SORRY

well it was a typo in hurry.
ofcourse FileNotFoundException is a checked exception and valid because it is subclass of IOException
 
srikanth reddy
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sandeep,

how come the method that throws the Arithmetic exception is valid since it is not the subset of IOException..

what do u say ???

thanks
sri
 
Sandeep Chhabra
Ranch Hand
Posts: 340
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
AirthmeticException is a RuntimeException.
And RuntimeExceptions are not Checked exceptions

Compiler does not flags any kind of error if a method is declared throwing a RuntimeException
 
srikanth reddy
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but in answer they didnt mention the Arithmetic exception .


thanks
sri
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well,

look at answer d)
"d) int methodOne( int c, long d ) throws ArithmeticException{}"
 
reply
    Bookmark Topic Watch Topic
  • New Topic