Skip to content

Instantly share code, notes, and snippets.

@MykolaBova
Created October 1, 2016 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MykolaBova/ae88bc20ea199d2d545d0a05d5580ca3 to your computer and use it in GitHub Desktop.
Save MykolaBova/ae88bc20ea199d2d545d0a05d5580ca3 to your computer and use it in GitHub Desktop.
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