Selasa, 12 Juni 2012

Polymorpishm overriding


Polymorpishm
overriding
class angka
{
                        public void kali(int a, int b)
                        {
                                                int hasil=a*b;
                                                System.out.println("++++++++++++++++++++++++++++");
                                                System.out.println("hasil kali ="+hasil);
                        }
}
class angkadua extends angka
{
                        public void kali(double a, double b)
                        {
                                                double hasil=a*b;
                                                System.out.println("hasil kali =" +hasil);
                                                System.out.println("++++++++++++++++++++++++++++");
                        }
}
class aritmatika
{
                        public static void main(String[]args)
                        {
                                    angkadua obj=new angkadua();
                                    obj.kali(10,9);
                                    obj.kali(10.0,9.0);
                        }
}



Tidak ada komentar:

Posting Komentar