As in C++, java as an OOP language supports method overriding
methodOverriding - get(String a,String b) : Takes two strings and returns them with a - between them
class getFullNamegetFullName - get(String a,String b) : Takes two strings and returns them with a space between them
{
public String get(String a,String b)
{
return a+" "+b;
}
}
class methodOverriding extends getFullName
{
public String get(String a,String b)
{
return a+"-"+b;
}
public static void main(String args[])
{
System.out.println("get() from methodOverriding "+new methodOverriding().get("87J8","2KH8"));
System.out.println("get() from getFullName "+new getFullName().get("Gutha","Gowtham"));
}
}
methodOverriding - get(String a,String b) : Takes two strings and returns them with a - between them
No comments:
Post a Comment