Polymorphism in Java

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/14

flashcard set

Earn XP

Description and Tags

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

15 Terms

1
New cards

What is polymorphism in Java?

The ability of an object to take many forms, typically allowing a single interface to represent different types.

2
New cards

What are the two types of polymorphism in Java?

Compile-time (static) polymorphism and Run-time (dynamic) polymorphism.

3
New cards

What is compile-time polymorphism?

Polymorphism achieved through method overloading during compilation.

4
New cards

What is run-time polymorphism?

Polymorphism achieved through method overriding, determined at runtime.

5
New cards

What is method overloading?

Defining multiple methods in the same class with the same name but different parameters.

6
New cards

What is method overriding?

Redefining a method in a subclass that already exists in the parent class.

7
New cards

Which keyword is used for method overriding?

@Override annotation is used to indicate method overriding.

8
New cards

What is dynamic method dispatch?

The process of resolving method calls at runtime based on the object’s actual type.

9
New cards

Can static methods be overridden?

No, static methods belong to the class and not to instances.

10
New cards

Can constructors be overloaded?

Yes, constructors can be overloaded in the same class with different parameter lists.

11
New cards

Can you override private methods?

No, private methods are not visible to subclasses, so they cannot be overridden.

12
New cards

What is the advantage of polymorphism?

Improves code reusability, flexibility, and maintainability.

13
New cards

What is an example of polymorphism in Java libraries?

The List interface can be implemented by ArrayList, LinkedList, etc.

14
New cards

What is late binding?

Binding which happens at runtime, used in dynamic polymorphism.

15
New cards

How does Java achieve run-time polymorphism?

Through method overriding and object reference pointing to subclass objects.