Welcome to Abdul Malik Ikhsan's Blog


Posted in Tutorial Java by samsonasik on May 9, 2007

**simpan file ini pada folder manusia

package manusia;
public class orang{
String nama;
public void isinama(String n){this.nama=n;}
public String tampilnama(){return nama;}
**simpan file ini pada folder animal

package animal;
public class hewan{
String panggilan,minum,terbang;
public void memanggil(String me){this.panggilan=me;}
public void menerbang(String mn){this.terbang=mn;}
public void editminum(String m){this.minum=m;}
public String implementasiminum(){return minum;}
public String implementasipanggil(){return panggilan;}
public String implementasiterbang(){return terbang;}

**sekarang kita buat file untuk memanggil sifat dari dua kelas di atas

import manusia.orang;
import animal.hewan;
class panggilduakelas{
public static void main(String args[]){
orang o=new orang();
hewan h=new hewan();
System.out.println(“”+o.tampilnama()+” sedang minum,…”+h.implementasiminum() );
System.out.println(“”+h.implementasipanggil()+” sedang terbang,…”+h.implementasiterbang());

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

%d bloggers like this: