Method Overloading and Overriding Flashcards

1
Q

What is the other name for method overloading?

A

Static Polymorphism

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How can you implement method overloading?

A

Implemented by having multiple methods with the same name in a class but with different arguments. Methods can have different number of parameters, different data type of parameters, different sequence of data type of parameters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why can’t the return type be different with method overloading?

A

This will lead to ambiguous behaviour.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do we implement method overriding?

A

To override a method, we just provide a different implementation of a method with the same name in the subclass.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Are we allowed to override a static method in java?

A

Java does not allow overriding a static method. If you create a static method with the same name in a subclass, then it is a new method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly