classes and objects
class pen{
int tip;
String color;
void setTip(int Newtip){
tip=Newtip;
}
void setColor(String newColor){
color=newColor;
}
}
public class oopj {
public static void main(String[] args){
pen p=new pen();
p.color="green";
// p.setColor("pink");
p.setTip(24);
System.out.println(p.color);
}
}
Comments
Post a Comment