Created
October 1, 2016 14:43
-
-
Save MykolaBova/ae88bc20ea199d2d545d0a05d5580ca3 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 { | |
protected int speedMax = 100; | |
public int getSpeedMax() { | |
return speedMax; | |
} | |
} | |
class SportCar extends Car { | |
protected int speedMax = 300; | |
public int getSpeedMax() { | |
return speedMax; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment