// get set method can be used to set private data members of a class // parent class Vehicle{ private String vehicleType; public String getVehicleType(){ return vehicleType; } public void setVehicleType(String type){ vehicleType = type ; } } // child public class Car extends Vehicle{ String modelType; public void showDetails(){ // vehicleType = "Car"; modelType = "Sports"; System.out.println(modelType + " " + getVehicleType()); } public static void main(String[] args){ Vehicle v1 = new Vehicle(); v1.vehicleType = "Honda"; // ERROR car.showDetails(); } }