1z0-808 Exam QuestionsBrowse all questions from this exam

1z0-808 Exam - Question 73


Which two are benefits of polymorphism? (Choose two.)

Show Answer
Correct Answer: BCD

Polymorphism allows objects to be treated as instances of their parent class rather than their actual class. This results in more dynamic code at runtime as the method to be invoked is determined at runtime rather than compile-time. Additionally, it creates more flexible and reusable code because the same method can operate on objects of different classes, provided they follow a common interface or inherit from a common superclass.

Discussion

5 comments
Sign in to comment
winfred_luOptions: CD
Jul 7, 2023

C: Method overriding is runtime polymorphism. The process in which call to the overridden method is resolved at runtime, also known as dynamic method dispatch. D: Method overriding works together with inheritance to enable code reuse of existing classes without the need for re-compilation.

dsmsOptions: BD
Aug 12, 2023

B: More flexible and reusable code: Polymorphism makes code more flexible and reusable because it allows objects of different classes to be treated as if they are objects of the same class. This means that if you have a method that works with an object of a particular class, you can also use that method with objects of other classes that inherit from that class or implement the same interface. This can save a lot of time and effort because you don't have to write a separate method for each class.

dsms
Aug 12, 2023

C: More dynamic code at runtime: Polymorphism makes code more dynamic at runtime because it allows the actual method that gets called to be determined at runtime rather than at compile time. This means that if you have a method that is overridden in a subclass, the version of the method that gets called will depend on the type of the object at runtime. This can lead to more flexible and powerful code that can adapt to different situations.

dsms
Aug 12, 2023

made a misprint. I mean D , not C

iSnoverOptions: BD
Oct 7, 2022

The correct answer is BD, not much to explain. Polymorphism makes the code more efficient in the sense that an object accesses features of the parent or child class and it also makes the code more flexible.

anmoldev2java
Nov 18, 2022

why cant C

netoplaxeOptions: CD
Jun 14, 2024

CD is the correct Answer. In Enthuware Exam-Pool you will find the same question and the correct answer which is CD