belajar java part 3 pertemuan 3

import java.util.*;

class Hewan {
public void suara() {
System.out.println(“Karakteristik nadanya ” +
“belum didefinisikan”);

class Ayam extends Hewan {

public void suara() {
System.out.println(“Ayam : Kukuruuukk…yuk”);

class Kucing extends Hewan {

public void suara() {
System.out.println(“Kucing : Meoong…meoong”);

class Kambing extends Hewan {

public void suara() {
System.out.println(“Kambing : Moooo…oo”);

class Macan extends Hewan {
public void suara() {
System.out.println(“Macan : wawwww “);

class contoh {

public static void main(String[] args) {

Scanner input= new Scanner(;
System.out.print(“masukan nama hewan = “);
String pilih=input.nextLine();

Hewan anda = new Ayam();
Hewan dia = new Kucing();
Hewan kamu = new Kambing();
Hewan saya= new Macan();

if (pilih.equals(“ayam”)){
} else if (pilih.equals(“kucing”)){
} else if (pilih.equals(“kambing”)){
} else if (pilih.equals(“macan”)){
} else {
System.out.println(“TIDAK ADA HEWAN”);


untuk menjalankannya simpan dengan nama “” tanpa tanda kutip
terimakasih selamat belajar


One response to “belajar java part 3 pertemuan 3

  1. Hehe I see that you are doing good buddy, lot’s of good articles. It would be good for you if you could invest in some ads you know, your Google rankings would be better probably. If your budget is tight, try to find other blog owners in similar niches and exchange links. Your blog looks like something that can do it big, it would be a shame if the people don’t see it 😉 Have a nice day

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:


You are commenting using your account. Logout /  Ubah )

Foto Google+

You are commenting using your Google+ account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )


Connecting to %s