Ask Question

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;

+2
Answers (1)
  1. 15 May, 16:14
    0
    The correct answer is d) Banana co;

    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;
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “We have the following class: class Banana { private: string s; int y; public: bool theMemberFunc (string); void setterForS (string); / / ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers