Inheritance in Java


Pre-requisite:
1.Java installed.

Inheritance means extending its method and variables.

File:herit.java

class sample
{
void get()
{
System.out.println(”Power of Eyes”);
}
void show()
{
System.out.println(”Tidal Waves”);
}
}
class herit extends sample
{
public static void main(String ar[])
{
sample s=new sample();
s.get();
s.show();
}
}

Sample Output:

Power of Eyes
Tidal Waves

Feel free to share your comments.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s