Answer:
class Case //Case class
{
String owner_name,color; //members to store information name and color
Case(String name,String color) //constrictor with two parameters
{
this.owner_name = name; //members initialization
this.color = color;
}
public String getName() //to get name
{
return owner_name;
}
public String getColor() //to get color
{
return color;
}
public String toString()//override string method
{
return "Case Owner: " + owner_name + ", " + "Color: "+ color;
}
}
class Main //test class
{
public static void main(String args[])
{
String na,color;
Case c = new Case("Joy","Green"); //create instance of class Case and set constructor parameters
na = c.getName();
color = c.getColor();
System.out.println(c);//print statement tp print instance of a class
System.out.println(c.toString()); //print with override toString
}
}
Explanation: