what are getter and setter methods code example
Example 1: getter and setters in js
var person={firstname:"chetha",secondname="kumar",get fullname()
{
return this.firstname+" "+this.secondname;
}
document.write(person.fullname);
var person={firstname:"chethan",secondname="kumar",course:"",set course(x)
{
this.course=x;
}
person.course="bca";
document.write(person.course);
Example 2: setter&getter java
public static void main(String[] args) {
Vehicle v1 = new Vehicle();
v1.setColor("Red");
System.out.println(v1.getColor());
}