Write syntax for class name fruit object mango
Answers
Answered by
0
Answer:
class Fruit
{
private String name, color;
public Fruit(String N, String C)
{
name = N;
color = C;
}
public void showInfo()
{
System.out.println(name);
System.out.println(color);
}
}
class Sample
{
public static void main(String args[])
{
Fruit mango = new Fruit("Mango", "Yellow");
mango.showInfo();
}
}
Similar questions