Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

help with Virtual methods!!

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again friends,
what are virtual methods?? why do we need them? why, they are called Virtual? does that mean they do not exist? how they are invoked? I know that I have to show some effort people, but , it is not clear enough here in my book, I really could not grasp it at all.I can post my book explaination here but, i know it wouldnt help? I appreciate your help and effort.
Ammar salem
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't heard of "virtual" method in Java. Do you mean that of C++, or abstract method of Java?
 
Ammar Salem
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No Daesung Park , it is in my java book. and i dont know what to do with it
regards,
 
author
Posts: 23883
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A virtual method (or function) is a distinction that doesn't really exist in Java. In C++, a virtual function is a function/method whose dispatch is determined at runtime -- basically, call the method based on the type of the object, not the type of the reference (pointer).

In Java, (instance) method calls are always dispatched at runtime. In other words, all non-static methods are virtual methods.

Henry
 
Ammar Salem
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks to all of you
respect,
Ammar
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With other words, virtual methods are methods that behave polymorphically. See also http://en.wikipedia.org/wiki/Virtual_function
 
Ammar Salem
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you ,Ranchers
 
Ammar Salem
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you,Ranchers
Regards
Ammar
[ January 23, 2008: Message edited by: Ammar Salem ]
 
Onion rings are vegetable donuts. Taste this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic