Question
URGENT!!!! Given the following class definition, which statements will instantiate an object of this class? Choose all that apply. class Cat { private String name;
URGENT!!!!
Given the following class definition, which statements will instantiate an object of this class? Choose all that apply.
class Cat { private String name; private int age; public Cat() { this.name = "no name"; this.age = 0; } public Cat(int initAge, String initName) { this.name = initName; this.age = initAge; } }
Cat myCat = new Cat("Fifi");
String yourCat = new Cat(3, "Fifi");
new Cat myCat = Cat(5, "Fwuffy");
new Cat myCat = Cat();
Cat yourCat = Cat(3, "Fifi");
none of these
new Cat myCat = Cat();
Cat yourCat = new Cat("Fifi", 3);
new yourCat = Cat(3, "Fifi");
Cat myCat = Cat();
Given the following class definition, which statements will instantiate an object of this class? Choose all that apply.
class Restaurant { private String name; private int rating; public Restaurant() { this.name = "no name"; this.rating = 0; } public Restaurant(int initRating, String initName) { this.name = initName; this.rating = initRating; } }
new Restaurant rr = Restaurant(5, "Chilli's");
String rest = new Restaurant(3, "Taco Bell");
Restaurant rest = new Restaurant("Taco Bell");
new rr = Restaurant(3, "Taco Bell");
Restaurant tacoBell = Restaurant();
Restaurant r = new Restaurant("Chilli's", 5);
new Restaurant diner = Restaurant();
new Restaurant chillis = Restaurant();
Restaurant diner = Restaurant("Taco Bell", 3);
none of these
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started