25 Lecture
CS304
Midterm & Final Term Short Notes
OVERLOADING VS. OVERRIDING
Overloading and overriding are both concepts in object-oriented programming that involve the use of functions in classes. Overloading refers to creating multiple functions with the same name but different parameters, while overriding refers to r
Important Mcq's
Midterm & Finalterm Prepration
Past papers included
Download PDF
What is overloading in object-oriented programming? a. Creating multiple functions with the same name but different parameters b. Redefining a function in a subclass that was originally defined in a superclass c. Both a and b Answer: a What is overriding in object-oriented programming? a. Creating multiple functions with the same name but different parameters b. Redefining a function in a subclass that was originally defined in a superclass c. Both a and b Answer: b Can overloaded functions have the same number of parameters? a. Yes b. No Answer: Yes Can overloaded functions have the same name and parameters? a. Yes b. No Answer: No Can overridden functions have the same name and parameters? a. Yes b. No Answer: Yes Is overloading static or dynamic polymorphism? a. Static b. Dynamic Answer: Static Is overriding static or dynamic polymorphism? a. Static b. Dynamic Answer: Dynamic Can overloading be done in the same class? a. Yes b. No Answer: Yes Can overriding be done in the same class? a. Yes b. No Answer: No What happens if an overridden function is called on an object of the subclass? a. The function defined in the superclass is called b. The function defined in the subclass is called c. Both functions are called Answer: b
Subjective Short Notes
Midterm & Finalterm Prepration
Past papers included
Download PDF
What is overloading and overriding in object-oriented programming? Answer: Overloading refers to creating multiple functions with the same name but different parameters, while overriding refers to redefining a function in a subclass that was originally defined in a superclass. What is the difference between overloading and overriding? Answer: Overloading is creating multiple functions with the same name but different parameters, while overriding is redefining a function in a subclass that was originally defined in a superclass. What is the purpose of overloading in object-oriented programming? Answer: Overloading allows a function to perform different tasks based on the parameters it is called with. What is the purpose of overriding in object-oriented programming? Answer: Overriding allows a subclass to provide a different implementation of a function defined in the superclass. Is overloading static or dynamic polymorphism? Answer: Overloading is an example of static polymorphism. Is overriding static or dynamic polymorphism? Answer: Overriding is an example of dynamic polymorphism. Can overloaded functions have different return types? Answer: Yes, overloaded functions can have different return types as long as their parameter lists differ. Can overridden functions have different return types? Answer: No, overridden functions must have the same return type as the function they are overriding. Can overloaded functions have different access modifiers? Answer: Yes, overloaded functions can have different access modifiers. Can overridden functions have different access modifiers? Answer: No, overridden functions must have the same access modifier as the function they are overriding.