Advertisement
CR7CR7

viechle

Jun 13th, 2022
974
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. class Vehicle {
  2.     protected String brand = "No brand";
  3. }
  4.  
  5. class Motorcycle extends Vehicle {
  6. }
  7.  
  8. class Car extends Vehicle {
  9. }
  10.  
  11. public class Main {
  12.  
  13.     public static void main(String []args) {
  14.         Motorcycle harley = new Motorcycle();
  15.         Car bmw = new Car();
  16.        
  17.         harley.brand = "Harley-Davidson";
  18.         bmw.brand = "BMW";
  19.        
  20.         System.out.println("Motorcycle: " + harley.brand);
  21.         System.out.println("Bmw       : " + bmw.brand);
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement