Skip to content

Instantly share code, notes, and snippets.

@rishi93
Created November 18, 2015 09:16
Show Gist options
  • Save rishi93/e8b23adea3922ce06a8a to your computer and use it in GitHub Desktop.
Save rishi93/e8b23adea3922ce06a8a to your computer and use it in GitHub Desktop.
Inheritance Example Data Members
import java.io.*;
class Feline
{
String type = "f";
public Feline()
{
System.out.println("feline");
}
}
class Cougar extends Feline
{
public Cougar()
{
System.out.println("cougar");
}
public void go()
{
type = "c";
System.out.println(this.type + " " + super.type);
}
}
public class test2
{
public static void main(String args[])
{
new Cougar().go();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment