class A
{
int x = 10;
}
class B extends A
{
float y = 50.25f;
}
class C extends B
{
char z = 'K';
}
class Inheritance
{
public static void main(String[] args)
{
System.out.println("Hello World!");
A s1 = new A();
System.out.println(s1.x);
B s2 = new B();
System.out.println(s2.x);
System.out.println(s2.y);
C s3 = new C();
System.out.println(s3.x);
System.out.println(s3.y);
System.out.println(s3.z);
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter