Skip to content

Instantly share code, notes, and snippets.

@thinkphp
Created July 6, 2026 14:48
Show Gist options
  • Select an option

  • Save thinkphp/540a5f66aad4d5cbc1cedc1824f1e06a to your computer and use it in GitHub Desktop.

Select an option

Save thinkphp/540a5f66aad4d5cbc1cedc1824f1e06a to your computer and use it in GitHub Desktop.
polimorfism.java
class Shape {
void draw() {
System.out.println("Desenez o forma geometrica");
}
}
//subclasa 1
class Circle extends Shape {
@Override
void draw() {
System.out.println("Desenez un cerc");
}
}
//subclasa 2
class Square extends Shape {
@Override
void draw() {
System.out.println("Desenez un Patrat");
}
}
//subclasa 3
class Triangle extends Shape {
@Override
void draw() {
System.out.println("Desenez un Triunghi");
}
}
public class Polimorfism {
public static void main(String[] args) {
Shape shape1 = new Circle();
Shape shape2 = new Square();
Shape shape3 = new Triangle();
shape1.draw();
shape2.draw();
shape3.draw();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment