Important Java Mcq 1

Which of the following is true about overloading and overriding?

a. Overloading can arbitrarily change the access of a method while overriding can only make it more restrictive.

b. Overloading happens at compile-time, while overriding happens at runtime.

c. Final methods can be overridden, but not overloaded.

d. The argument list of overloaded methods must be of the same data type (unlike overridden methods)

Answer:

b. Overloading happens at compile-time, while overriding happens at runtime.

Explanation:

Method overloading is the compile-time polymorphism where more than oneĀ methods share the same name with different parameters or signature and different return Type. Method overriding happens at runtime because the method gets resolved at run-time.

Related MCQs
Aniket Malik

Aniket Malik

CERTIFIED TUTOR/TRAINER WITH 300+ REVIEWS

Facing difficulty with

this concept?