Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tutorial;
- public class Overridingex {
- public void suarahewan(){
- System.out.println("hewan memiliki suara");
- }
- }
- class Anjing extends Overridingex{
- public void suaraAnjing(){
- System.out.println("Anjing : guk guk guk");
- }
- }
- class Kucing extends Overridingex{
- public void suaraKucing(){
- System.out.println("Kucing : meow meow meow");
- }
- }
- class main{
- public static void main(String[] args) {
- Anjing dog = new Anjing();
- dog.suaraAnjing();
- Kucing cat = new Kucing();
- cat.suaraKucing();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement