public class overriding {
String nama;
String jenis;
String bahanbakar;
public void mesin(){
System.out.println("Memiliki Mesin");
}
public void nama(){
System.out.println("Alat transportasi darat dan laut");
}
public void jenis(){
}
public void bahanbakar(){
}
}
class bus2 extends overriding{
@Override
public void nama(){
System.out.println("Nama Transportasi = "+nama);
}
@Override
public void jenis(){
System.out.println("Jenis Transportasi = "+jenis);
}
@Override
public void bahanbakar(){
System.out.println("Bahan Bakar = "+bahanbakar);
}
}
class motor2 extends overriding{
@Override
public void nama(){
System.out.println("nama transportasi = "+nama);
}
public void jenis(){
System.out.println("Jenis Transportasi = "+jenis);
}
public void bahanbakar(){
System.out.println("Bahan Bakar = "+bahanbakar);
}
}
class pesawat2 extends overriding{
@Override
public void nama(){
System.out.println("nama transportasi = "+nama);
}
@Override
public void jenis(){
System.out.println("jenis transportasi ="+jenis);
}
@Override
public void bahanbakar(){
System.out.println("Bahan Bakar = "+bahanbakar);
}
public static void main(String[] args) {
polimorpishm.alattransportasi x = new polimorpishm.alattransportasi();
x.nama();
x.mesin();
bus2 y =new bus2();
y.nama="Bus";
y.jenis="darat";
y.bahanbakar="solar";
y.nama();
y.jenis();
y.bahanbakar();
motor2 u =new motor2();
u.nama="motor";
u.jenis="darat";
u.bahanbakar="bensin";
u.nama();
u.jenis();
u.bahanbakar();
pesawat2 t =new pesawat2();
t.nama="Pesawat";
t.jenis="Udara";
t.bahanbakar="avgas";
t.nama();
t.jenis();
t.bahanbakar();
}
}
Posted by 09.04 and have
1 komentar
, Published at
.,sout e angger copas ae??
BalasHapus.,kliru loh output e :D