0% found this document useful (0 votes)
5 views1 page

Inheritance Example in Java Code

The program demonstrates inheritance by defining a Father class with an integer field a, then defining a Child class that extends Father and is able to access the inherited field a to print its value of 10 in the main method.

Uploaded by

Akanksha Gupta
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Inheritance Example in Java Code

The program demonstrates inheritance by defining a Father class with an integer field a, then defining a Child class that extends Father and is able to access the inherited field a to print its value of 10 in the main method.

Uploaded by

Akanksha Gupta
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

//Program to show inheritance

class Father { final int a=10; }

class Child extends Father { public static void main(String arg[]) { Child c=new Child(); [Link](c.a); } }

You might also like