Answer the following questions about constructors. public class Cat { public Cat
ID: 3597514 • Letter: A
Question
Answer the following questions about constructors.
public class Cat
{
public Cat()
{ ... }
public Cat(String name)
{ ... }
public Cat(String name, double age)
{ ... }
public Cat(String name, double age, double weight)
{ ... }
public Cat(Cat twin)
{ ... }
}
14. Fill in the blank so that a new Cat is created and the first constructor is used
• Cat c1 = ___________________________;
15. Fill in the blank so that a new Cat is created and the second constructor is used
• Cat c2 = ___________________________;
16. Fill in the blank so that a new Cat is created and the third constructor is used
• Cat c3 = ___________________________;
17. Fill in the blank so that a new Cat is created and the fourth constructor is used
• Cat c4 = ___________________________;
18. Fill in the blank so that a new Cat is created and the fifth constructor is used
• Cat c5 = ___________________________;
Explanation / Answer
14 - Cat c1 =new Cat(); as it is default constructor it is passes without any arguments.
15-Cat c2 =new Cat("Kunal"); a string is passed as the argument for thsi constructor requires a string.
16-Cat c3=new Cat("abc",20.15); in this a string with a double value is passed as for this constructor the arguments are of type string and double.
17-Cat c4=new Cat("abc",20.15,154.45); in this a string name with a double value age and another value height is passed to this constructor the arguments are of type string ,double,and double.
18-Cat c5=new Cat(c4) as the arguments consists of a object of the same class so it is a case of copy constructor so an object of the class will be passed as n calling argument.