• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Which two are benefits of polymorphism?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got a question which I think the answer is wrong.

The question is:

Which two are benefits of polymorphism?

A. Faster code at runtime

B. More efficient code at runtime

C. More dynamic code at runtime

D. More flexible and reusable code

E. Code that is protected from extension by other classes

They say that the correct answers are: B and D. However, I think that the correct answers are: C and D.

What do you think?
 
author
Posts: 23928
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Please QuoteYourSources.

Henry
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Marco Pierre Fernandez Burgos wrote:They say that the correct answers are: B and D. However, I think that the correct answers are: C and D.
What do you think?


I think any one of B, C or D could be correct, depending on what they mean by "dynamic". So, on that basis, I'd say that B and D is "more correct" than C and D.

The reason why B is correct may be answered by asking yourself the following question: If you didn't have polymorphism, what would your code look like?

This is a question that C programmers have wrestled with for many years.

Winston
 
Sheriff
Posts: 7123
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...and welcome to the Ranch!
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote: If you didn't have polymorphism, what would your code look like?

This is a question that C programmers have wrestled with for many years.

Winston



It would be objects or structures with pointers to functions. Thats how we did polymorphism.
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Shawn Lau wrote:It would be objects or structures with pointers to functions. Thats how we did polymorphism.


OK, but it takes a lot of building. And unless you know the type beforehand, you end up with a lot of dispatch code (anyone remember COM?).

Winston
 
Your mind is under my control .... your will is now mine .... read this tiny ad
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic