Inheritance Code Solution

Inheritance Code Solution 

class Vehicle{ 
 private int regd; 
 private String m; 
  
 public void setm(String m) { 
 this.m = m; 
 } 
 // initialize regd 
 public void setregd(int regd) { 
 this.regd = regd; 
 } 
 // access m 
 public String getm() { 
 return this.m; 
 } 
 // access regd 
 public int getregd() { 
 return this.regd; 
 } 
class Car extends Vehicle 
private String name; 
 private String color; 
 public Car(String name,String color) 
 { 
 super(); 
 this.name=name; 
 this.color=color;  
 } 
 public String getName() 
 { 
 return this.name; 
 } 
  
 public String getColor() 
 { 
 return this.color; 
 } 
}

Comments