I’m not sure about one thing. There are two things in object oriented programming.
-
Constructor
-
Method
Which one of these can be overloaded and which one overridden?
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
both can be overloaded.
overloading means having two or more methods or constructors with exactly same name but different signatures. some thing like :
or for methods :
edited :
bebin, overriding usually comes with inheritance , when the super class implements a method but the subclass needs to implement that method in other way like :
in super class:
but in subclass :
and about constructor overriding the following line are from CollinD and i am quoting it :
“Constructors are not normal methods and they cannot be “overridden”. Saying that a constructor can be overridden would imply that a superclass constructor would be visible and could be called to create an instance of a subclass. This isn’t true… a subclass doesn’t have any constructors by default (except a no-arg constructor if the class it extends has one). It has to explicitly declare any other constructors, and those constructors belong to it and not to its superclass, even if they take the same parameters that the superclass constructors take.
The stuff you mention about default no arg constructors is just an aspect of how constructors work and has nothing to do with overriding.”