• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Polymorphism Question

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I have been testing myself on Polymorphism concepts, and came across this question

Which of the keywords above are often used with polymorphic methods?
a. final
b. abstract
c. virtual
d. static

answers:
a) a
b) b
c) c
d) a, b, and d
e) a, b, c, and d

My initial thought is that a (final) and d(static) are not used with polymorphic methods (final cannot be re-defined, and static is not part of the instance, but to the class itself), but to my knowledge you can use abstract and virtual methods for polymorphism.  So couldn't the answer be (b) or (c)? Would someone be able to provide the answer or provide some clarity here? Thanks
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Are you sure virtual is a valid keyword in Java?
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, when you post something that you came across elsewhere, whether in a book or website or wherever, please cite your sources.
 
Erik Ponder
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Junilu Lacar wrote:Welcome to the Ranch!

Are you sure virtual is a valid keyword in Java?



Wow, I was too focused on the concept that I forgot that java does not use the virtual keyword . Thanks for pointing this out to me
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic