void setup(){
Parrot p1= new Parrot(); // Reference to the Object of name P1
TalkingParrot tp1= new TalkingParrot();
p1.Speaking();
p1.Eating();
tp1.Speaking();
}
void draw() {
}
////////////////
class Parrot {
// Class of Parrot . or Parent or Super Class
public void Walking() { // Method
println("I am walking");
}
public void Eating() {
println("I am hngry...I want to eat!!");
}
public void Sleeping() {
println("Time to sleep zZzZZZZZ...");
}
public void Speaking() {
println("tain tain tain...");
}
}
//////////////
class TalkingParrot extends Parrot{ // Inheritance
public void Speaking() { // Method OverRiding
println("Take me out of this cage right now!!!");
}
}
No comments:
Post a Comment