GeekInterview.com
Series: Subject: Topic:
Question: 19 of 573

final method

having said a final method can be overloaded(default in d same class) plz explain me if there is anything missing in this code ? class Base { public final doSomething(Object o) { System.out.println("Object"); } } class Derived extends Base { public doSomething(Integer i) { System.out.println("Int"); } } public static void main(String[] args) { Base b = new Base(); Base d = new Derived(); b.doSomething(new Integer(0)); d.doSomething(new Integer(0)); } This will print: Object Object MY DOUBT IS IN THE DERIVED CLASS METHOD ! IS DER D FINAL KEYWORD MISSING ??
Asked by: gova007 | Member Since Feb-2010 | Asked on: Jan 22nd, 2012

View all questions by gova007

Showing Answers 1 - 3 of 3 Answers
neetub

Answered On : Feb 2nd, 2012

View all answers by neetub

No there is no coding mistake. Only there has to be return type for method doSomething() as void.

  
Login to rate this answer.
santhosh

Answered On : Feb 23rd, 2012

In the main method,you simply change the "base d" as "Derived d" you get "object" and "int" as a output.also returned type is required.

  
Login to rate this answer.
sampra

Answered On : Mar 6th, 2012

View all answers by sampra

final method can be overload but cannt override

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.