Java Course

OverRiding

class Human
{
public void age()
{
System.out.println("I am not adult");
}
}

class Person extends Human
{
public void age()
{
System.out.println("I am adult");
}
}


class Program
{
public static void main(String [ ] args)
{
Person a = new Person();
a.age();
}
}

 

OverLoading 

class Program
{
public static void max(int a, int b)
{
if (a > b)
{
System.out.println(a);
}
else
{
System.out.println(b);
}
}

public static double max(double a, double b)
{
if (a > b)
{
return a;
}
else
{
return b;
}
}

public static void main(String [ ] args)
{
max(10,16);
System.out.println(max(10.2,13.34));
}


}



Dodaj komentarz






Dodaj

© 2013-2024 PRV.pl
Strona została stworzona kreatorem stron w serwisie PRV.pl