The following program is Overloading or Overriding?
public class PolymorphismEx {
public int sampleMethod(int a) {
return a;
}

public String sampleMethod(int a) {
return "Is it Overloading or Overriding???";
}
}

Answers were Sorted based on User's Feedback



The following program is Overloading or Overriding? public class PolymorphismEx { public int samp..

Answer / venkat asha reddy

it is neither overloading nor overriding. it throws method
ambiguity exception while compiling

Is This Answer Correct ?    16 Yes 1 No

The following program is Overloading or Overriding? public class PolymorphismEx { public int samp..

Answer / kvsravindrareddy

Its kind of overriding, but the program will give compilation
error. why because Overriding cannot be possible within the
same class. or Duplicate method cannot possible within the
same class.

Is This Answer Correct ?    13 Yes 5 No

The following program is Overloading or Overriding? public class PolymorphismEx { public int samp..

Answer / jagadish

Duplicate Method sampleMethod(int a) Error Message will display

Is This Answer Correct ?    1 Yes 0 No

The following program is Overloading or Overriding? public class PolymorphismEx { public int samp..

Answer / hemanth

Its Neither Overloading nor overriding, Because for Overloading there should some Variation in argument list and for overriding the return type(if Primitive) should be same.
int method(int a)
{
}
String method(int a)
{
}
arguments should be different for overloading
return type should be same(if primitive) for overriding

so its improper which results in compile time error.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is the difference between static synchronize() metod and synchronize() method?

1 Answers   Polaris,


Are functions objects in java?

1 Answers  


Can you override a private or static method in java?

1 Answers  


How big is a pointer?

1 Answers  


What is java thread dump, how can we get java thread dump of a program?

1 Answers  


How do you replace a string in java?

1 Answers  


Can we sort arraylist in java?

1 Answers  


wht is mean by dirty read?

1 Answers  


What is logical variable?

1 Answers  


What are the types of literals?

1 Answers  


How to find the largest value from the given array.

1 Answers  


In real time project which driver did u use? What is the main functionality of the Prepared Statement?

3 Answers   Photon,


Categories