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?


October 10, 2008 13:03:18 #7
 bharathnav   Member Since: October 2008    Total Comments: 2 

RE: Overriding Methods
 
"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 
Latest Answer: Because at run time, the super class will compiled first, so it will gives the run time error. ..."

if the object has been created to the subclass and both the methods are non static then the method we overriden doesn't produce any errors or exceptions.
     

 

Back To Question