Created
November 18, 2015 09:16
-
-
Save rishi93/e8b23adea3922ce06a8a to your computer and use it in GitHub Desktop.
Inheritance Example Data Members
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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