Escolar Documentos
Profissional Documentos
Cultura Documentos
with Java
(CT038-3-2)
Abstract Classes
Interfaces
Polymorphism
Object Oriented Programming
Topic & Structure of the lesson
• Polymorphism
• Abstract Classes & Methods
• Example
• Interfaces
• Example
• Interfaces vs. Abstract Classes
// constructor
public Point(int xValue, int yValue) {
// implicit call to Object constructor occurs here
x = xValue; // no need for validation
y = yValue; // no need for validation
}
// constructor
public Circle(int x, int y, double radiusValue) {
super( x, y ); // call Point constructor
setRadius( radiusValue );
}
// set radius
public void setRadius(double radiusValue) {
radius = (radiusValue < 0.0 ? 0.0 : radiusValue);
}
CT038-3-2 Object-Oriented Development with Java Abstraction
Abstract Classes & Methods
Example
// return radius
public double getRadius(){
return radius;
}
System.exit( 0 );
} // end main