Share on Google+Share on Google+

SCJP Module-4 Question-6

The sample program given below tests your understanding of method overloading and method overriding in Java.

Given the following sample code:

public class Example5{
public float Twin(float a, float b) {...
public float Twin(float a1, float b1) { ...}


How can above code will be corrected without changing the 'method's name', 'type' & 'number' of argument? changing the name of the argument. changing the body (code between braces) changing name of the class putting one method into another subclass of this class

Answer :


Explanation :

By putting one method into another subclass of this class, will correct this code. After this change overloading is converted into overriding.


Posted on: July 9, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null