?
Solved

Explain Polymorphism in java

Posted on 2011-10-18
1
Medium Priority
?
355 Views
Last Modified: 2013-11-24
Explain Polymorphism in java
0
Comment
1 Comment
 
LVL 47

Accepted Solution

by:
for_yan earned 2000 total points
ID: 36990898
Polymorphism means that if you have


class A {
void method1() {
// some stuff
}

}

class B extends A {

void method1(){
//anotyher stuff
}

}

now somewhere in you code you'll create instance

A  b = new B();
b.method1();

in this case //another stuff will be executed, not //some stuiff

this is callled polymorphism - when instance was created as subclass
and it excutes metyhod which is overriden in scbclass it will always
execute the stiff in the method of subclass, not in the method of class

let me know if there ias somethiong not clear about it


0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month5 days, 13 hours left to enroll

589 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question