Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Vehicle {
- protected String brand = "No brand";
- }
- class Motorcycle extends Vehicle {
- }
- class Car extends Vehicle {
- }
- public class Main {
- public static void main(String []args) {
- Motorcycle harley = new Motorcycle();
- Car bmw = new Car();
- harley.brand = "Harley-Davidson";
- bmw.brand = "BMW";
- System.out.println("Motorcycle: " + harley.brand);
- System.out.println("Bmw : " + bmw.brand);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement