Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

Difference between interface and abstract class with ex.

4 Answers   Cognizant, Tech Mahindra,


What are void methods?

0 Answers  


Can an anonymous class be declared as implementing an interface and extending a class in java programming?

0 Answers  


Can there be an abstract method without an abstract class?

0 Answers  


Can you override static methods?

0 Answers  


Is a method a procedure?

0 Answers  


What are untrusted applets?

0 Answers  


what is the difference between object and class

10 Answers   IBM,


Can an unreachable object become reachable again?

3 Answers  


What does int [] mean in java?

0 Answers  


What is boolean flag in java?

0 Answers  


What will happen inside init() in servlet. my interviewer asked servlet lifecycle. i said "once servlet is loaded in to memory init() will be called which performs servlet initialization " . Again interview asked what values will be initialized . what is difference between init() and init(ServletConfig config).

2 Answers   Infinite Computer Solutions, TCS,


Categories