Class Inner Java

class human :

package human;

abstract class manusia{

protected String nama;

protected int jmlhKaki;

public manusia(String nama, int kaki){

this.nama=nama;

jmlhKaki=kaki;

}

public abstract void suara();

public static void makan(){

}

public void isManusia(){

System.out.println(“nama :”+nama);

System.out.println(“jumlah kaki :”+jmlhKaki);

}

}

interface Human{

public void suara();

public void ketawa();

}

class rizka extends manusia implements Human{

public rizka(){

super(“Rizka”,2);

}

public void suara(){

System.out.println(“\nHallo…..”);

}

public void ketawa(){

System.out.println(“ckckckckckck…..”);

}

public static void makan(){

System.out.println(“delicious…….”);

}

public static void main(String[] args){

rizka a = new rizka();

a.isManusia();

a.suara();

a.ketawa();

a.makan();

}

}

tampilan output :

j_2

Class bear :

package class_inner;

abstract class binatang{

protected String nama;

protected int jmlhKaki;

public binatang(String nama, int kaki){

this.nama=nama;

jmlhKaki=kaki;

}

public abstract void suara();

public static void makan(){

}

public void isBinatang(){

System.out.println(“nama :”+nama);

System.out.println(“jumlah kaki :”+jmlhKaki);

}

}

interface Human{

public void suara();

public void ketawa();

}

class tedyBear extends binatang implements Human{

public tedyBear(){

super(“tedyBear”,4);

}

public void suara(){

System.out.println(“\nyuhuuu…….”);

}

public void ketawa(){

System.out.println(“wakakakakak…wakakakaak”);

}

public static void makan(){

System.out.println(“mak nyuuuusss…..top markotop….”);

}

public static void main(String[] args){

tedyBear a = new tedyBear();

a.isBinatang();

a.suara();

a.ketawa();

a.makan();

}

}

tampilan output :

j_1

Class ayam :

package ayam;

abstract class ayam2{

protected String nama;

protected int jmlhKaki;

public ayam2(String nama, int kaki){

this.nama=nama;

jmlhKaki=kaki;

}

public abstract void suara();

public static void makan(){

}

public void isAyam2(){

System.out.println(“nama :”+nama);

System.out.println(“jumlah kaki :”+jmlhKaki);

}

}

interface Human{

public void suara();

public void ketawa();

}

class ciken extends ayam2 implements Human{

public ciken(){

super(“Ciken”,2);

}

public void suara(){

System.out.println(“\nkok, kok, kooook…..”);

}

public void ketawa(){

System.out.println(“kok, kok,kok, petooook…”);

}

public static void makan(){

System.out.println(“kok, kok, uenak…..”);

}

public static void main(String[] args){

ciken a = new ciken();

a.isAyam2();

a.suara();

a.ketawa();

a.makan();

}

}

 

tampilan output :

j_3

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s