Overview
1. Subclass that try to modify behaviour that inheritted from superclass.
2. Aim: subclass has more specific behaviour .
3. Done by return declare method property of parent class at subclass.
- Method declaration in subclass must equal to found at super class. sameness in:
- name
- return type
- parameter list (total, type, and sequence)
- Method in parent class called overriden method
- Method in subclass called overriding method.
Example:
public class Animal {
public void SetVoice() {
System.out.println(“Blesepblesep”);
}
}
public void SetVoice() {
System.out.println(“Blesepblesep”);
}
}
public class Dog extends Animal {
public void SetVoice() {
System.out.println(“Hug hug”);
}
}












Leave a comment