Visitor

Sunday, December 15, 2013

Program Java dengan keyword super

class Person
{
protected String name;
protected int age;

public Person(String name, int age)
{
this.name = name;
this.age  = age;
}

//metode
public void info()
{
System.out.println("Nama : "+this.name);
System.out.println("Age  : "+this.age);
}
//akhir kelas program
}

class Employ extends Person
{
private String noKaryawan;
//konstruktor
public Employ (String noKaryawan, String name, int age)
{
super (name, age);
this.noKaryawan = noKaryawan;
}

//metode
public void info()
{
System.out.println("No. Karyawan : "+this.noKaryawan);
super.info();
}
}


public class KonstruktorSuperKelas
{
public static void main (String[]args)
{
Employ programer1 = new Employ ("12345678", "Yanto", 32);
programer1.info();
}

}

0 komentar

Post a Comment