GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

  GeekInterview.com  >  Interview Questions  >  J2EE  >  Core Java

 Print  |  
Question:  Overriding Methods

Answer: Suppose a Super Class method throws an exception and this method is Overriden in the subclass with no exception. Now if you create a super class reference that has a subclass object. This throws a compile time error, Why?


August 08, 2008 02:56:33 #1
 frustu   Member Since: August 2008    Total Comments: 1 

RE: Overriding Methods
 
Sub class's method will compile successfully as subclass's method can either specify the exception or not in its signature.But if its specifying it should be that exception,any of the sub classes of exception or any runtime exception. Sub class method can 't add any new exception
     

 

Back To Question