Memanggil Method Melalui Super

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package memanggilSuper;
class orang{
private String nama, alamat;
private int umur;

// konstruktor
orang(String nama, String alamat, int umur){
this.nama=nama;
this.alamat=alamat;
this.umur=umur;
}

// method
void info(){
System.out.println(“Nama : “+nama);
System.out.println(“Alamat : “+alamat);
System.out.println(“Umur : “+umur);
}

}

class pegawai extends orang{
protected String noPegawai;

// kontruktor
pegawai(String noPegawai, String nama,String alamat, int umur){
super(nama,alamat,umur);
this.noPegawai=noPegawai;
}

// method
void info(){
System.out.println(“No. Pegawai : “+noPegawai);
super.info();
}
}
/**
*
* @author ANGGA
*/
public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
pegawai angga=new pegawai(“12345″,”ANGGA ARI WIJAYA”,”Gresik”,19);
angga.info();
}

}

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 )

Foto Google

You are commenting using your Google 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 )

Connecting to %s