Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 1 2 pts (TCO 2) Only those class members that are part of the implement

ID: 3857036 • Letter: Q

Question

Question 1
2 pts
(TCO 2) Only those class members that are part of the implementation of the class should be declared as ______.

available

banned

private

public



Question 2
2 pts
(TCO 2) _____ and _____ are other terms for getters and setters.

Constructors; destructors

None of the above

Public; private

Retrievals; putters

Question 3
2 pts
(TCO 2) Which of the following statements is/are true?

None of the above

The code within public methods is actually part of the implementation because the user cannot see it.

The implementation is totally hidden from the user.

All of the above

A change to the implementation should not require a change to the user’s code.


Question 4
2 pts
(TCO 2) A Waiter is responsible for taking the order from the Customer based on the menu, informing the Chef of the order and delivering the requested food back to the Customer. A Chef is responsible for preparing the food and notifying the Waiter when the food is ready. The Customer is responsible for placing an order from the menu. In identifying the interface of the Customer object, which of the following would you consider as (an) appropriate message(s) the Customer should respond to?

All of the above

Only B and C

“How old are you?”

“How would you like your steak? Rare, medium rare, or well done?”

“What would you like to eat?”



Question 5
2 pts
(TCO 5) A _____ initializes a newly created object, while a _____ releases back the resources to the system when an object is not used anymore.

constructor; destructor

class; method

default constructor; class

getter; destructor



Question 6
2 pts
(TCO 5) Which of the following method pairs are not examples of method overloading?

public int Cook(int x) ; public void Cook(int x, double y)

Only A and C

public int Add(int x) ; public int Add(int y)

public void Mark() ; public int Move(int x)

All of the above


Question 7
2 pts
(TCO 5) Consider the following class definition and the object instantiation.

class House
{
     private:
    int age;
     double salesPrice;

     public:
    House()
     {
          age = 1;
          salesPrice = 2.0;
     }
    House(int a, double sp)
     {
          age = a;
          salesPrice = sp;
     }

    int getAge()
     {
         return age;
     }
    double getSalesPrice()
     {
         return salesPrice;
     }
    ~House() { }
} ;
int main()
{
      int tempAge=0;
    int tempPrice=0;

      House ranch();
return 0;
}

Using the main() method to access the members of the object, which of the following statement is correct?

tempPrice = House.SalesPrice();

ranch.age = 3;

cout<<”The house price is: “ << ranch.SalesPrice();

ranch.salePrice = 250000.0;



Question 8
2 pts
(TCO 2) Can two classes each define a method with the same name?

Yes, this is possible.

No, this is not possible because the compiler would not know which method to call.

Yes, but only if the classes have the same name.

Yes, as long as the method has the same number of parameters in each class.



Question 9
2 pts
(TCO 5) Which error handling technique(s) is/are appropriate when developing an application?

Check for potential problems and throw an exception.

All of the above

Check for potential problems, catch the mistake, and try to fix it.

Check for potential problems and abort the application when a problem is encountered.



Question 10
2 pts
(TCO 2) Which is an appropriate choice for a static (or otherwise called class) attribute in a Car class?

numberOfCars

None of the above

numberOfPassengerSeats

numberOfDoors

Explanation / Answer

1. private
2.None of the above correct amswer is accessors and mutators
3.The implementation is totally hidden from the user.

4.Only B and C

customer should respond to these two questions.

“How would you like your steak? Rare, medium rare, or well done?”

“What would you like to eat?”
5. A ___constructor__ initializes a newly created object, while a ___destuctor__ releases back the resources to the system when an object is not used anymore.
6. ans:public int Add(int x) ; public int Add(int y)

C++ allows specification of more than one function of the same name in the same scope. These are called overloaded functions and are described in detail in Overloading. Overloaded functions enable programmers to supply different semantics for a function, depending on the types and number of arguments.
7.

The class data members can be accessed only through setter and getter functions. The getAge() and getSalesPrice() are getter functions given in the program.

To display the value of SalesPrice, the cout statemet is cout<<”The house price is: “ << ranch.getSalesPrice();

*NOTE: in the options, change ranch.SalesPrice(); to ranch.getSalesPrice(); as the setter function name given in the program is getSalesPrice();.

Hence, the correct option will be cout<<”The house price is: “ << ranch.getSalesPrice();


8.Yes, this is possible

two different classes with same function name is very much possible because the two functions will be called by creating objects of classes .

if one class is inherited by another class then there may be ambiguity which function should be invoked.in this case answer will be No, this is not possible because the compiler would not know which method to call.
9. Check for potential problems, catch the mistake, and try to fix it.
10. numberOfDoors

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote