Created
October 1, 2016 14:57
-
-
Save MykolaBova/8a2bfc7bf78808e06ca64a8a5211c769 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 ToString2 { | |
public static void main(String[] args) { | |
Car car = new SportCar(); | |
System.out.println(car); | |
} | |
} | |
class Car { | |
protected int speedMax = 100; | |
public int getSpeedMax() { | |
return speedMax; | |
} | |
public String toString() { | |
return "This is car"; | |
} | |
} | |
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