30.5k views
3 votes
We have the following class:

class Banana

{

private:

string s;

int y;

public:

bool theMemberFunc (string);

void setterForS(string); // setter for s

string getterForS(); // getter for s

};

Instantiate a static object of Banana named co.

a)int Banana;

b)co.Banana = new;

c)Banana = new class;

d)Banana co;

User Caffeine
by
5.1k points

1 Answer

5 votes

Answer:

The correct answer is d) Banana co;

Step-by-step explanation:

In Java everything is an object, for example when we declare a variable x of type int we usually do in this way, determine the class we are going to instance and then the name of our object:

  • int x;

On the example above we instantiate an object of int named x.

For this exercise we have to instantiate an object of type Banana that is going to be named co.

  • Banana co;
User Kevik
by
5.6k points