Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners dynamic polymorphism
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


muthu
dynamic polymorphism
1 Answer(s)      3 years and 3 months ago
Posted in : Java Beginners


Develop with suitable hierarchy, classes for Point, Shape, Rectangle, Square, Circle, Ellipse, Triangle, Polygon, etc. Design a simple test application to demonstrate dynamic polymorphism.?


Advertisement
View Answers

July 21, 2011 at 12:49 PM


class point{
void show(){
System.out.println("This is the Point Base class");
}
}
class shape extends point{
void display(){
System.out.println("Different shapes can be developed with different number of points");
}
}
class rectangle extends shape{
int l,b;
void getdata(int x,int y){
l=x;b=y;
}
void area(){
System.out.println("Length:"+l);
System.out.println("Breadth:"+b);
System.out.println("Area:"+(l*b));
}
}
class square extends shape{
int a;
void gdata(int x){
a=x;
}
void area(){
System.out.println("Side:"+a);
System.out.println("Area:"+(a*a));
}
}
class circle extends shape{
int r;
void get(int x){
r=x;
}
void area(){
System.out.println("Radius:"+r);
System.out.println("Area:"+(3.14*r*r));
}
}
class triangle extends shape{
int b,h;
void tdata(int x,int y){
b=x;h=y;
}
void area(){
System.out.println("Base:"+b);
System.out.println("Height:"+h);
System.out.println("Area:"+(0.5*b*h));
}
}
class ShapeTest{
public static void main(String args[]){
rectangle r = new rectangle();
square s = new square();
circle c = new circle();
triangle t = new triangle();
r.show();
s.display();
System.out.println("");
System.out.println("Rectangle:");
System.out.println();
r.getdata(12,6);
r.area();
System.out.println("");
System.out.println("Square:");
System.out.println();
s.gdata(7);
s.area();
System.out.println("");
System.out.println("Circle:");
System.out.println();
c.get(5);
c.area();
System.out.println("");
System.out.println("Triangle:");
System.out.println();
t.tdata(4,7);
t.area();
}
}


Related Tutorials/Questions & Answers:
dynamic polymorphism
dynamic polymorphism  Develop with suitable hierarchy, classes for Point, Shape, Rectangle, Square, Circle, Ellipse, Triangle, Polygon, etc. Design a simple test application to demonstrate dynamic polymorphism
dynamic polymorphism
dynamic polymorphism  give an example for dynamic polymorphism?   Dynamic polymorphism is where a class overrides a superclass method... of Dynamic Polymorphism that will develop suitable hierarchy, classes for Point, Shape
Advertisements
Dynamic Polymorphism - Java Beginners
Dynamic Polymorphism  Develop with suitable hierarchy, classes for Point, Shape, Rectangle, Square, Circle, Ellipse, Triangle, Polygon, etc. Design a simple test application to demonstrate dynamic polymorphism.? Thanks
Dynamic polymorphism - Java Beginners
Dynamic polymorphism  Develop with suitable hierarchy, classes for point, shape, rectangele, square, circle,ellipse, triangle, polygon, etc. Design a simple test application to demonstrate dynamic polymorphism.. Thanks
polymorphism
polymorphism  can we achieve without overriding polymorphism
Java run time polymorphism
Java run time polymorphism  What is run-time polymorphism or dynamic method dispatch
Run time polymorphism
Run time polymorphism  What is run time polymorphism or dynamic method dispatch
Polymorphism - Java Beginners
Or we can also say that a polymorphism is possible in both state Static and Dynamic. Coz polymorphism means in many forms. So do not get confused of it just...Polymorphism  type of polymorphism  In Java polymorphism
Polymorphism in actionscript
Polymorphism in actionscript  Hi....... Please implement How polymorphism works on actionscript? Thanks  Ans: class Worker extends Employee { override public function receivePayment():Number { return 0
Polymorphism - Java Beginners
Polymorphism  what is dynamic polymorphism? with example  Hi friend, Dynamic polymorphism is run time polymorphism. Thanks ... static. Dynamic polymorphism is where a class overrides a superclass method
Does hibernate support polymorphism?
Does hibernate support polymorphism?  Hi, Does hibernate support polymorphism? thanks
Polymorphism in Hibenate - Hibernate
Polymorphism in Hibenate  Hi, How polymorphism inheritance and association achieved in hibernate. Thank u in advance
Polymorphism in Java 7
This tutorial describe concept of Polymorphism. It is one of OOPs concept
polymorphism - Java Beginners
polymorphism  what is polymorphism? what is the advantage of function overloading? explain the concept of operator overloading?  Hi Friend, Please visit the following links: http://www.roseindia.net/help/java/m
Polymorphism - Java Beginners
Q: Isn't it possible to detect the method's associatation, in case of method... is run (run-time polymorphism) ? Isn't java compiler having such an ability... Polymorphism means the ability to take more than one form. Polymorphism
runtime polymorphism - Development process
runtime polymorphism  how run time polymorphism is achieved  Hi Friend, The run-time polymorphism is basically the Method Overriding.Here super class reference is referring to subclass object and compiler does
Polymorphism : Method Overriding
In this tutorial you will learn another concept of polymorphism that is method overriding
DYNAMIC BINDING
DYNAMIC BINDING  WHAT IS DYNAMIC BINDING
PHP Polymorphism Function
PHP Polymorphism Function: The PHP Polymorphism Method is one of the feature of OOP language. Generally we get polymorphism in two ways: Compile time Run time Compile time polymorphism PHP is like function overloading, operator
dynamic report
dynamic report  i need complete code for generating dynamic report in jsp
Polymorphism : Method Overloading
In this tutorial you will learn one of polymorphism concept that is method overloading with example in Java 7
What is Polymorphism in Java?
Polymorphism in Java means a subclass, though having its own unique behavior... IS-A relationship is polymorphic. In Polymorphism, common interface is used while writing code. Single polymorphism is achieved by method overriding while multiple
Dynamic keyword
Dynamic keyword  hi....... What is the dynamic keyword used for in flex? give me the answer ASAP Thanks  Ans: Dynamic keyword-> Specifies that instances of a class may possess dynamic properties added
dynamic method dispatch - Java Beginners
dynamic method dispatch  can you give a good example for dynamic method dispatch (run time polymorphism)   Hi Friend, In dynamic method dispatch,super class refers to subclass object and implements method overriding
dynamic textfields
dynamic textfields  Hi, I am a fresher and joined recently in one company. they gave me a desktop application project using swings.here is my detailed spec Screen 1 - The user enters the ingredients from a food product, saves
dynamic jquery statement
dynamic jquery statement  dynamic jquery statement
Dynamic form
Dynamic form  I need to make a dynamic form using jsp for example, i will need a list of items which when we select one option another list is modified ( like 2 lists of countries and citys ), and also a radio button wich once
dynamic form
dynamic form  I need to make a dynamic form using php, for example, i will need a list of items which when we select one option another list is modified ( like 2 lists of countries and citys from a dtabase ), and also a radio
dynamic calender
dynamic calender  hi i need the code to "insert date using GUI"   Hi Friend, Try the following code: import java.awt.*; import java.awt.event.*; import javax.swing.*; class DatePicker{ int month
( Inheritance,need help in Polymorphism, Overriding) - Java Beginners
( Inheritance,need help in Polymorphism, Overriding)  can any one please help me create this application,thank you Advanced Concepts with Classes( Inheritance, Polymorphism, Overriding) Employees in a company are divided
 

 

 

DMCA.com