program superclass

Superclass mobil:

 

public class mobil {

private String Roda;

private String Kemudi;

private String Sadel;

public mobil (String Roda, String Kemudi, String Sadel)

{

this.Roda = Roda;

this.Kemudi = Kemudi;

this.Sadel = Sadel;

}

public void info()

{

System.out.println(“mobil mempunyai : ” + this.Roda);

System.out.println(“mobil mempunyai : ” + this.Kemudi);

System.out.println(“mobil mempunyai : ” + this.Sadel);

}

}

avansa.java

public class avansa extends mobil

{

private static int jmlRoda = 4;

public avansa (String Roda, String Kemudi, String Sadel, int jmlRoda)

{

super (Roda, Kemudi, Sadel);

jmlRoda++;

}

public void info()

{

System.out.println(“Jumlah Roda : ” + jmlRoda);

super.info();

}

}

avansacoba.java

public class avansacoba

{

public static void main(String[] args)

{

avansa obj1 = new avansa(“Roda”,”Kemudi”,”Sadel”,2);

obj1.info();

System.out.println(“Method tambahan Jumping”);

}

}

output :

 

init:

deps-jar:

compile-single:

run-single:

Jumlah Roda : 4

mobil mempunyai : Roda

mobil mempunyai : Kemudi

mobil mempunyai : Sadel

Method tambahan Jumping

BUILD SUCCESSFUL (total time: 0 seconds)

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: