Created
October 29, 2023 20:12
-
-
Save rebekah/4eb1a31c95fabce2672dde26f2bed381 to your computer and use it in GitHub Desktop.
Basic Inheritance
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
//Vehicle.java | |
public class Vehicle { | |
String color; | |
} | |
//Truck.java | |
public class Truck extends Vehicle { | |
int bedLength; | |
} | |
//TruckDemo.java | |
class TruckDemo { | |
public static void main(String[] args){ | |
Truck myTruck = new Truck(); | |
myTruck.bedLength = 2; | |
System.out.println(myTruck.bedLength); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment