Inheretance and polymorphism
View Answers
December 26, 2008 at 6:41 AM
Hi friend,,
import java.awt.*;
import java.awt.Graphics2D;
public class RotationDemo extends StrokeThicknessExample {
private Color[] colors = {
Color.white, Color.green
};
public void paintComponent(Graphics g) {
clear(g);
Graphics2D graph = (Graphics2D)g;
drawGradientCircle(graph);
drawThickCircleOutline(graph);
// Move the origin to the center of the circle.
graph.translate(185.0, 185.0);
for (int i=0; i<20; i++) {
System.out.println("I >>>>>>>>>>>>>" + i);
graph.rotate(Math.PI/8.0);
graph.setPaint(colors[i%2]);
graph.drawString("Rose", 0, 0);
}
}
public static void main(String[] args) {
WindowUtilities1.openInJFrame(new RotationDemo(), 380, 400);
}
}
--------------------------------------------
import java.awt.*;
public class StrokeThicknessExample extends FontExample {
public void paintComponent(Graphics g) {
clear(g);
Graphics2D g2d = (Graphics2D)g;
drawGradientCircle(g2d);
drawBigString(g2d);
drawThickCircleOutline(g2d);
}
protected void drawThickCircleOutline(Graphics2D g2d) {
g2d.setPaint(Color.blue);
g2d.setStroke(new BasicStroke(8));
g2d.draw(getCircle());
}
public static void main(String[] args) {
WindowUtilities1.openInJFrame(new StrokeThicknessExample(),
380, 400);
}
}
---------------------------------------
import java.awt.*;
public class FontExample extends GradientPaintExample {
public FontExample() {
GraphicsEnvironment env =
GraphicsEnvironment.getLocalGraphicsEnvironment();
env.getAvailableFontFamilyNames();
setFont(new Font("Goudy Handtooled BT", Font.PLAIN, 70));
}
protected void drawBigString(Graphics2D g2d) {
g2d.setPaint(Color.black);
g2d.drawString("Roseindia", 25, 215);
}
public void paintComponent(Graphics g) {
clear(g);
Graphics2D g2d = (Graphics2D)g;
drawGradientCircle(g2d);
drawBigString(g2d);
}
public static void main(String[] args) {
WindowUtilities.openInJFrame(new FontExample(), 380, 400);
}
}
December 26, 2008 at 6:42 AM
import javax.swing.*;
import java.awt.*;
import java.awt.geom.*;
public class ShapeExample1 extends JPanel {
private Ellipse2D.Double circle =
new Ellipse2D.Double(10, 10, 350, 350);
private Rectangle2D.Double square =
new Rectangle2D.Double(10, 10, 350, 350);
public void paintComponent(Graphics g) {
clear(g);
Graphics2D g2d = (Graphics2D)g;
g2d.fill(circle);
g2d.draw(square);
}
protected void clear(Graphics g) {
super.paintComponent(g);
}
protected Ellipse2D.Double getCircle() {
return(circle);
}
public static void main(String[] args) {
WindowUtilities1.openInJFrame(new ShapeExample1(), 380, 400);
}
}
--------------------------------------
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class WindowUtilities1 {
public static void setNativeLookAndFeel() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch(Exception e) {
System.out.println("Error occur: " + e);
}
}
public static JFrame openInJFrame(Container content,
int width,
int height,
String title,
Color bgColor) {
JFrame frame = new JFrame(title);
frame.setBackground(bgColor);
content.setBackground(bgColor);
frame.setSize(width, height);
frame.setContentPane(content);
frame.addWindowListener(new ExitListener());
frame.setVisible(true);
return(frame);
}
public static JFrame openInJFrame(Container content,
int width,
int height,
String title) {
return(openInJFrame(content, width, height, title, Color.white));
}
public static JFrame openInJFrame(Container content,
int width,
int height) {
return(openInJFrame(content, width, height, content.getClass().getName(), Color.white));
}
public void windowClosing(WindowEvent event) {
System.exit(0);
}
}
December 26, 2008 at 6:46 AM
Related Tutorials/Questions & Answers:
Inheretance and polymorphism - Java BeginnersInheretance and polymorphism hope guys you will help ,thank you. merry christmas and happy new year to you!
Exercise 1.) A point the x-y plane is coordinate and y-coordinate.Design the class Point that can store and process
Inheretance and polymorphism - Java BeginnersInheretance and polymorphism FRIEND IS THIS ONE CODE???
hope guys you will help ,thank you. merry christmas and happy new year to you!
1.) A point the x-y plane is coordinate and y-coordinate.Design the class Point
Advertisements
Inheretance and polymorphism - Java BeginnersInheretance and polymorphism hope guys you will help ,thank you. merry christmas and happy new year to you!
1.) A point the x-y plane is coordinate and y-coordinate.Design the class Point that can store and process a point
polymorphismpolymorphism can we achieve without overriding
polymorphism dynamic polymorphismdynamic 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 Polymorphism in actionscriptPolymorphism in actionscript Hi.......
Please implement
How
polymorphism works on actionscript?
Thanks Ans:
class Worker extends Employee {
override public function receivePayment():Number {
return 0
dynamic polymorphismdynamic 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
inheretance java code - Java Beginnersinheretance java code this is my code , Friend please can you make a Testclass all of this code is connected to each other.
class Point
{
private int x;
private int y;
public Point (int x, int y)
{
this.x = x
inheretance java program - Java Beginnersinheretance java program this is my code , Friend can you make a Testclass all of this code is connected to each other.please can you make a testclass to this codes thank you so much friend.
class Point
{
private int x
Polymorphism - Java BeginnersPolymorphism type of polymorphism In Java
polymorphism...
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
Dynamic polymorphism - Java BeginnersDynamic 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
Dynamic Polymorphism - Java BeginnersDynamic 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
polymorphism - Java Beginnerspolymorphism 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 BeginnersPolymorphism what is dynamic
polymorphism? with example Hi friend,
Dynamic
polymorphism is run time
polymorphism.
Thanks The term static
polymorphism is associated with overloaded methods
because
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 processruntime 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
PHP Polymorphism FunctionPHP
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
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
Polymorphism ;
OOPs revolve around the four concepts:
1. Encapsulation
2.
Polymorphism..., programmatically.
Here we will discuss
Polymorphism briefly:
--
Polymorphism... behavior to method calls of the same name.
--
Polymorphism does not allow
Method Overloading in java;
Polymorphism is the
capability of an object to respond
uniformly... implementations.
In java the concept of
Polymorphism
is achieved in two ways... the compile time
polymorphism.
-- Overloaded methods are always the part
Encapsulation in JavaEncapsulation along with Inheritance,
Polymorphism, and Abstraction are the four concepts of Object Oriented Programming (OOPs). Encapsulation in Java is the technique of binding or wrapping the data and the codes in a class private
java - Java Interview Questionsjava what is compiletime
polymorphism and what is dynamic
polymorphism a small
ex for both There are two type of
polymorphism i.e.
static(compiplation time) and
Dynamic
Polymorphism(Run Time).
In case
java - Java Beginnersjava Can you provide me the concepts of class hierarchy with a suitable diagram and concepts of
polymorphism with dynamic binding with a programming example for each please
pls help me with this questionpls help me with this question how to write a program in C++ using encapsulation,
polymorphism,inheritance and abstraction?(all these concepts should come in a single program
java - Java Beginnersjava Can you provide me the example program which uses all the concepts like encapsulation ,inheritance ,
polymorphism in a single program
oops conceptsoops concepts What is
polymorphism?Explain with an example.
What is abstraction?Explain with an example.
What is inheritance?Explain with an example.
What is encapsulation?Explain with an example
java - Java Beginnersjava Develop with suitable hierarchy, classes for Point, Shape, Rectangle, Square, Circle,
Ellipse, Triangle, Polygon, etc. Design a simple test application to demonstrate
dynamic
polymorphism java basicsjava basics What are Encapsulation, Inheritance and
Polymorphism... the code that depends on the public interface of your classes.
Polymorphism... or Class.
In simple words, One function - different implementations.
Polymorphism java tricky questionjava tricky question can we have dynamic
polymorphism without overriding in java..??
I know tht itz possible..but hav no idea how..?
can any1 help me out.
Thanks in advance
GARBAGE COLLECTOR;In order to achieve run-time
polymorphism in java following supports needed...
polymorphism at later time with the help of dynamic method dispatch mechanism.../refers and finally help to achieved run-time
polymorphism.
//Example : java
core java - Java Interview Questionscore java - Use of
polymorphism in object oriented programming Hi all, I am digging for an example of
polymorphism in object orient programming. Can anyone please help? Use of
polymorphism in object orient
java the concept of
Polymorphism inJava to calculate teh charges
Is Java object oriented?Is Java object oriented? Hi,
Is Java object oriented?
Thanks
Hi,
Java is object oriented programming language. It is supports OPPS concepts:
Object
Class
Inheritance
Polymorphism
Abstraction
Encapsulation
All