Created
October 1, 2016 14:30
-
-
Save MykolaBova/3da6a6d313b4d8d3b60cb2a07d5868fa to your computer and use it in GitHub Desktop.
This file contains 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
class HideInstanceVariable { | |
public static void main(String[] args) { | |
Car car = new SportCar(); | |
System.out.println(car.getSpeedMax()); | |
} | |
} | |
class Car { | |
private int speedMax = 150; | |
public int getSpeedMax() { | |
return speedMax; | |
} | |
} | |
class SportCar extends Car { | |
private int speedMax = 300; | |
@Override | |
public int getSpeedMax() { | |
return speedMax; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment