C# Questions

profiledmpiney198x
q2.docx

1. (TCO 2) Only those class members which are hidden from users of the class are part of the _____ of the class. (Points : 2)

       interface        implementation        constructors        GUI (graphical user interface)

Question 2.2. (TCO 2) _____ and _____ are other terms for getters and setters. (Points : 2)

       Constructors; destructors        Public; private        Retrievals; putters        None of the above 

Question 3.3. (TCO 2) Which of the following statements is/are true? (Points : 2)

       If a method is public, it is considered part of the class implementation.        If you declare an attribute as private, you do not have to worry about tracking down every piece of code that might have changed the attribute when debugging.        While designing a class you add as many interfaces as possible, trying to cover all possible future user needs.        All of the above        None of the above

Question 4.4. (TCO 2) A Waiter is responsible for taking the order from the Customer, 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 Chef object, which of the following would you consider as (an) appropriate message(s) the Chef should respond to? (Points : 2)

       “Take a pound of ground meat, add a chopped onion, salt, pepper, parsley and broil for 15 minutes until the burger becomes golden brown.”        “What do you do after work?”        “Prepare a steak, medium-rare.”        All of the above        Only A and C

Question 5.5. (TCO 5) The purpose of a(n) _____ is to initialize the object's data members when an object is instantiated. (Points : 2)

       methods        constructor        class        destructor 

Question 6.6. (TCO 5) Which of the following method pairs are not examples of method overloading? (Points : 2)

       public void Roll() ; public int Move(int x)        public int Charge(int x) ; public int Charge(int y)        public int Subtract() ; public void Subtract()        All of the above        Only B

Question 7.7. (TCO 5) Consider the following class definition.

public class Rose {      private int petals;      private double cost;      public Rose()      {            petals = 30;            cost = 0.0;      }      public Rose(int p)      {            petals = p;            cost = 0.0;      }      public int Petals()      {           return petals;       }      public void Cost(int amount)      {           cost = amount;       }     ~Rose(){} }

Which of the following is/are true? (i) The data member cost can be set to a new value, by a user of this class. (ii) Console.WriteLine(“The rose has: “ + Rose.Petals() + “ petals.”); is a valid statement. (iii) There is a destructor in the class. (Points : 2)

       i.        ii        only i and iii        None are true        All are true 

Question 8.8. (TCO 2) Assume a class has a method called ‘ComputeAverage()’. Can another class have a method called ‘ComputeAverage()’? (Points : 2)

       Yes, as long as the method performs the same or similar task.        Yes, this is possible.        No, because the compiler cannot distinguish the appropriate method to call.        None of the above

Question 9.9. (TCO 5) Which error handling technique(s) is(are) appropriate when developing an application? (Points : 2)

       Check for potential problems and abort the application when a problem is encountered.        Check for potential problems and throw an exception.        Check for potential problems, catch the mistake and try to fix it.        All of the above

Question 10.10. (TCO 2) Which is an appropriate choice for a static attribute in a Building class? (Points : 2)

       numberOfBuildings        numberOfApartments        numberOfFloors        None of the above