Inheriting the method in a class

class Q
{
void display()
{System.out.println(“Good Morning”);}
}
class R extends Q
{
void display()
{System.out.println(“Good Afternoon”);} }
class PQRdemo
{
public static void main(String[] args)
{
R r1 = new R();
r1.display(); }}
Output
Good Afternoon

 

Share

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.