Java 15 - simple Inheritance
Sun Nov 26 2023 17:02:33 GMT+0000 (Coordinated Universal Time)
Saved by
@Java
class LabTask15
{
int a=10;
void friend()
{
System.out.println("my friends");
}
}
class Best extends LabTask15
{
int b=20;
void bestu()
{
System.out.println("My Bestie1 is Siva.");
System.out.println("My Bestie2 is Sai.");
}
public static void main(String[] args)
{
LabTask15 n1=new LabTask15();
System.out.println(n1.a);
Best n2=new Best();
System.out.println(n2.b);
n2.bestu();
}}
class A
{
int a=10;
void read()
{
System.out.println("This is read method");
}
}
class B extends A
{
int b=20;
void add()
{
System.out.println("This is addition");
}
}
content_copyCOPY
Comments