program Interface
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package inheritance;
/**
* @author Gi0
*/
public class hewan_inheritance
String warnakulit;
int jumlahkaki;
void warnakulit (String warna)
warnakulit=warna;
[Link] ("Warna Kulitnya : " +warnakulit);
void jumlahkaki (int jumlah)
jumlahkaki=jumlah;
[Link] ("Jumlah Kakinya : " +jumlahkaki);
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package inheritance;
/**
* @author Gi0
*/
public class kelinci
public static void main (String[] args)
habitatdarat kelinci = new habitatdarat();
[Link] ("Kelinci memiliki ciri-ciri : ");
[Link]("Putih");
[Link](4);
[Link]("Tumbuhan");
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package inheritance;
/**
* @author Gi0
*/
public class habitatdarat extends hewan_inheritance
String makan;
public void pemakan (String makanan)
makan=makanan;
[Link] ("Makanannya : " +makan);
Polymorphisme
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* @author Gi0
*/
public class hewan {
int kaki;
String nama, makanan;
void inputData(String x,String y, int z){
kaki = z ;
nama =x ;
makanan = y ;
void cetak(){
[Link]("nama hewan ="+ nama);
[Link]("makanan ="+ makanan);
[Link]("jumlah kaki ="+ kaki);
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* @author Gi0
*/
public class panggil {
public static void main (String[]args){
hewan r= new hewan();
[Link]("kura-kura","sayuran dan buah-buahan", 4);
[Link]();
Output: