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...


What restrictions are placed on method overloading and
method overriding?

Answers were Sorted based on User's Feedback



What restrictions are placed on method overloading and method overriding?..

Answer / muthusenthil

Restriction imposed on Method Overloading are
a) should done with in a same class.
b) it should have same name of overloading method.
c) its arguments or parameter should be different
irrespective of return type.

Restriction imposed on Method Overriding are
a) should done with its derived class
b) should have same name of parent method and arguments
too.

Is This Answer Correct ?    34 Yes 7 No

What restrictions are placed on method overloading and method overriding?..

Answer / aks

The rules for overriding a method are as follows:
¡ The argument list must exactly match that of the
overridden method.
¡ The return type must exactly match that of the
overridden method.
¡ The access level must not be more restrictive than that
of the overridden method.
¡ The access level can be less restrictive than that of
the overridden method.
¡ The overriding method must not throw new or broader
checked exceptions

The rules for overloading a method are as follows:
¡ Overloaded methods must change the argument list.
¡ Overloaded methods can change the return type.
¡ Overloaded methods can change the access modifier.
¡ Overloaded methods can declare new or broader checked
exceptions.
¡ A method can be overloaded in the same class or in a
subclass.

Is This Answer Correct ?    20 Yes 2 No

What restrictions are placed on method overloading and method overriding?..

Answer / javaguy

About said are absolutely correct. I would like to add some
more to method override.

The class/program who is overriding method should have
orverriding method visibility / access modifiers should be
same are greater but should not be lower.

Is This Answer Correct ?    9 Yes 1 No

What restrictions are placed on method overloading and method overriding?..

Answer / aditya mohata

in method overloading we hav to hav the methods in the same
class n they hav to hav diff signatures so as to avoid
ambiguity.they hav to hav the same method name.

in method overriding we hav to hav the same name of the
methods n hav to hav them in different classes with same
signatures.

Is This Answer Correct ?    12 Yes 5 No

What restrictions are placed on method overloading and method overriding?..

Answer / shamik

@ above one correction ...

the return type of overriding method can be a subtype of the type returned in the overridden method .It need not be exactly same .

Is This Answer Correct ?    6 Yes 1 No

Post New Answer

More Core Java Interview Questions

explain Anonynous inner class?

6 Answers   TCS,


What is the difference between Error, defect,fault, failure and mistake?

0 Answers   HCL,


What is meant by attribute?

0 Answers  


Where to store local variables?

0 Answers   Aspiring Minds,


Define how does a try statement determine which catch clause should be used to handle an exception?

0 Answers  


Is linkedlist thread safe in java?

0 Answers  


What is the disadvantage of synchronization?

0 Answers  


What is byte [] in java?

0 Answers  


In java, how we can disallow serialization of variables?

0 Answers  


Are arrays passed by reference in java?

0 Answers  


What are possible key words, we can use to declare a class?

2 Answers   Tech Mahindra,


What is the syntax and characteristics of a lambda expression? Explain

0 Answers  


Categories