Preview:
package csd.java.lab;

class ParentClass{

int a;

void SetData(int x) {

a=x;

}

}

class ChildClass extends ParentClass{

void ShowData() {

System.out.println("Value of a is\t"+a);

}

}

public class W2_ii_SInheritance {

public static void main(String[] args) {

ChildClass c1=new ChildClass();

c1.SetData(25);

c1.ShowData();

}

}
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