contoh Abstract class di java

share cara buat abstract class di java….

public class karyawan extends kantor{

public String name;

public karyawan(String kepala,String name){
super(kepala);
this.name = name;
}

public String getName(){
return name;
}
public void setName(String name){
this.name = name;
}

}

public class kantor implements perusahaan{

public String kepala;
public String ceo = “Santri”;

public kantor(String kepala){
this.kepala = kepala;
}
public String getKepala(){
return kepala;
}
public void setKepala(String kepala){
this.kepala = kepala;
}

@Override
public void setCeoName(String CEO){
this.ceo = ceo;
}
@Override
public String getCeoName(){
return ceo;
}
}

public interface perusahaan{
void setCeoName(String CEO);
String getCeoName();

}

public class Panggil{

public static void main(String[] args){
karyawan c = new karyawan(“anwar”,””);
System.out.println(c.getName() + c.getCeoName());

komputerdesktop m = new komputerdesktop(3,4,5);
System.out.println(m.getBesar() +” ” + m.getHarga() +” ” + m.getJumlah());
}

}

public abstract class komputer implements perusahaan{
public int jumlah,besar,harga;

public komputer(int jumlah,int besar,int harga){
this.jumlah = jumlah;
this.besar = besar;
this.harga = harga;
}
public int getJumlah(){
return jumlah;
}
public int getBesar(){
return besar;
}
public int getHarga(){
return harga;
}

}

public class komputerdesktop extends komputer{

public String namek;

public komputerdesktop(int harga,int besar, int jumlah){
super(harga,besar,jumlah);
}

@Override
public void setCeoName(String CEO){

}
@Override
public String getCeoName(){
return “suck”;
}
}

emmm,,,klo salah mohon comment…please..:D

About these ads

4 thoughts on “contoh Abstract class di java

  1. It is rare for me to uncover something on the web thats as entertaining and intriguing as what you have got here. Your page is sweet, your graphics are great, and whats much more, you use source that are relevant to what youre saying. That you are undoubtedly one in a million, well done! ffkbekagbbcf

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