60,487 views
15 votes
15 votes
2) Using two statements, create an object bestDessertPlace, followed by an object bestIndianFood.

3)Given the code below, how many objects are created?
Restaurant bestIndianFood = new Restaurant();
Restaurant bestSushi = new Restaurant();
Restaurant bestCoffeeShop = new Restaurant();
int newRating;

4) Object bestSushi is of type Restaurant. Type a statement that sets bestSushi's name to "Sushi Station".

5) Type a statement to print bestCoffeeShop's name and rating.

User JVDL
by
2.5k points

1 Answer

26 votes
26 votes

Answer:

Step-by-step explanation:

The following code is written in Java and assumes that the available main class is the Restaurant class and that the other objects are all from the Restaurant class or a subclass of it.

2) Restaurant bestdessertplace = new Restaurant();

Restaurant bestindianfood = new Restaurant();

3) This snippet of code creates 3 individual objects which are bestIndianFood, bestSushi, bestCoffeeShop.

4) bestSushi.name = "Sushi Station";

5) System.out.println(bestCoffeeShop.name + " " + bestCoffeeShop.rating);

User Jtruelove
by
3.0k points