Polymorphism: request behaviour consistently without knowing the full class of the objectIdentifying the type of the object during polymorphismRun-time Polymorphism in Java without “abstract”?Field access and Memory Allocation for Objects in Java PolymorphismStatic Polymorphism with CRTP: Using the Base Class to Call Derived MethodsPolymorphism on a static data member of a C++ classHow is dynamic polymorphism useful when I cant call derived class methods with base class referenceC# polymorphous design without castingHow do I call a super class method from sub class object which has overridden?How to know whether it is a compile-time polymorphism or run-time polymorphism?Class polymorphism without “new” in C++
Is it more effective to add yeast before or after kneading?
Why does this image of Jupiter look so strange?
Can I take NEW (still in their boxes) PC PARTS in my checked in luggage?
What's the lowest risk highest reward I can invest in for 5 years?
What Secular Civic Space Would Pioneers Build For Small Frontier Towns?
Subverting the emotional woman and stoic man trope
How to deal with my team leader who keeps calling me about project updates even though I am on leave for personal reasons?
How do you use the interjection for snorting?
If an object moving in a circle experiences centripetal force, then doesn't it also experience centrifugal force, because of Newton's third law?
How can I repair this gas leak on my new range? Teflon tape isn't working
Hiking with a mule or two?
Why is there not a feasible solution for a MIP?
Is there any iPhone SE out there with 3D Touch?
Is it a good idea to leave minor world details to the reader's imagination?
SOQL Join Opportunity, OpportunityLineItem, and Custom Object
Is it right to extend flaps only in the white arc?
My Project Manager does not accept carry-over in Scrum, Is that normal?
Why is (inf + 0j)*1 == inf + nanj?
Hilbert's hotel: why can't I repeat it infinitely many times?
Is it really necessary to have a four hour meeting in Sprint planning?
Examples of "unsuccessful" theories with afterlives
Co-Supervisor comes to office to help her students which distracts me
Safely hang a mirror that does not have hooks
How to say "cheat sheet" in French
Polymorphism: request behaviour consistently without knowing the full class of the object
Identifying the type of the object during polymorphismRun-time Polymorphism in Java without “abstract”?Field access and Memory Allocation for Objects in Java PolymorphismStatic Polymorphism with CRTP: Using the Base Class to Call Derived MethodsPolymorphism on a static data member of a C++ classHow is dynamic polymorphism useful when I cant call derived class methods with base class referenceC# polymorphous design without castingHow do I call a super class method from sub class object which has overridden?How to know whether it is a compile-time polymorphism or run-time polymorphism?Class polymorphism without “new” in C++
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to understand the concept of Polymorphism. I can't understand the following sentence:
we can request behaviour consistently without knowing the full class of the object
The book shows an example code showing three classes and then creates a reference of superclass and then use the reference to invoke derive class methods which is a usual technique for implementing polymorphism as shown below:
class B extends A
void callme()
System.out.println(“Inside B’s callme method”);
//Q. What can you say about callme( )?
class C extends A
void callme()
System.out.println(“Inside C’s callme method”);
class Dispatch
public static void main(String args[ ])
A a = new A(); //obj of Type A
B b = new B(); //obj of Type B
C c = new C(); //obj of Type C
A r;
r = a; // r refers to an A object
r.callme();
r = b;//r refers to a B object
r.callme();
r = c;// r refers to a C object
r.callme();
Some body please guide me "Why are we saying we don't have information about the full class of object"? Constructor can tell us about the class. Also all the classes are listed here. What can be a real scenario?
polymorphism
add a comment
|
I am trying to understand the concept of Polymorphism. I can't understand the following sentence:
we can request behaviour consistently without knowing the full class of the object
The book shows an example code showing three classes and then creates a reference of superclass and then use the reference to invoke derive class methods which is a usual technique for implementing polymorphism as shown below:
class B extends A
void callme()
System.out.println(“Inside B’s callme method”);
//Q. What can you say about callme( )?
class C extends A
void callme()
System.out.println(“Inside C’s callme method”);
class Dispatch
public static void main(String args[ ])
A a = new A(); //obj of Type A
B b = new B(); //obj of Type B
C c = new C(); //obj of Type C
A r;
r = a; // r refers to an A object
r.callme();
r = b;//r refers to a B object
r.callme();
r = c;// r refers to a C object
r.callme();
Some body please guide me "Why are we saying we don't have information about the full class of object"? Constructor can tell us about the class. Also all the classes are listed here. What can be a real scenario?
polymorphism
add a comment
|
I am trying to understand the concept of Polymorphism. I can't understand the following sentence:
we can request behaviour consistently without knowing the full class of the object
The book shows an example code showing three classes and then creates a reference of superclass and then use the reference to invoke derive class methods which is a usual technique for implementing polymorphism as shown below:
class B extends A
void callme()
System.out.println(“Inside B’s callme method”);
//Q. What can you say about callme( )?
class C extends A
void callme()
System.out.println(“Inside C’s callme method”);
class Dispatch
public static void main(String args[ ])
A a = new A(); //obj of Type A
B b = new B(); //obj of Type B
C c = new C(); //obj of Type C
A r;
r = a; // r refers to an A object
r.callme();
r = b;//r refers to a B object
r.callme();
r = c;// r refers to a C object
r.callme();
Some body please guide me "Why are we saying we don't have information about the full class of object"? Constructor can tell us about the class. Also all the classes are listed here. What can be a real scenario?
polymorphism
I am trying to understand the concept of Polymorphism. I can't understand the following sentence:
we can request behaviour consistently without knowing the full class of the object
The book shows an example code showing three classes and then creates a reference of superclass and then use the reference to invoke derive class methods which is a usual technique for implementing polymorphism as shown below:
class B extends A
void callme()
System.out.println(“Inside B’s callme method”);
//Q. What can you say about callme( )?
class C extends A
void callme()
System.out.println(“Inside C’s callme method”);
class Dispatch
public static void main(String args[ ])
A a = new A(); //obj of Type A
B b = new B(); //obj of Type B
C c = new C(); //obj of Type C
A r;
r = a; // r refers to an A object
r.callme();
r = b;//r refers to a B object
r.callme();
r = c;// r refers to a C object
r.callme();
Some body please guide me "Why are we saying we don't have information about the full class of object"? Constructor can tell us about the class. Also all the classes are listed here. What can be a real scenario?
polymorphism
polymorphism
edited May 26 at 10:25
halfer
15.3k7 gold badges63 silver badges129 bronze badges
15.3k7 gold badges63 silver badges129 bronze badges
asked Mar 28 at 16:34
user2994783user2994783
53 bronze badges
53 bronze badges
add a comment
|
add a comment
|
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55402714%2fpolymorphism-request-behaviour-consistently-without-knowing-the-full-class-of-t%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55402714%2fpolymorphism-request-behaviour-consistently-without-knowing-the-full-class-of-t%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown