Created
December 19, 2016 17:25
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
// base class Vahicle | |
class Vahicle{ | |
int maxspeed = 300; | |
} | |
//sub class Car extending vahicle | |
class Car extends Vahicle{ | |
int maxspeed = 500; | |
void display(){ | |
// print the max speed of base class | |
System.out.println("Max Speed subclass "+maxspeed); | |
System.out.println("Max Speed"+super.maxspeed); | |
} | |
} | |
// Driver program to Myclass | |
class MyClass{ | |
public static void main(String args[]){ | |
Car obj = new Car(); | |
obj.display(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment