1 TCO 1 Which of the following statements isare true Points
1. (TCO 1) Which of the following statements is/are true? (Points : 5)
A. The implementation of a class should be hidden, as best practice.
B. The state of an object is defined as the attributes and behaviors of that object.
C. Striving for the fullest possible interface of a class, incorporating possible future class needs, is the goal when designing a class.
D. An interface of a class defines what messages an object can respond to.
All are true
None are true
Only A, B, and D are true
Question 2.2. (TCO 2) Which of the following components of a class definition do not have a return type? (Points : 5)
Public member methods
Accessor/mutator methods
Constructors
Private member methods
None of the above
Question 3.3. (TCO 5) Which of the following method pairs are not examples of method overloading? (Points : 5)
public void Dance() ; public int Dance(int x)
public int Walk(int x, int y) ; public void Walk(int x, int y, int z)
public int Jump(int x, int y) ; public int Jump(int y, int x)
All of the above
Only A and B
Question 4.4. (TCO 1) Which of the following statements is/are true? (Points : 5)
In object-oriented programming we design the program as a set of cooperating methods.
The procedural paradigm permits the modeling of a software system in a more natural way compared to the object-oriented paradigm.
Abstraction is the process of extracting the high level information about a category entity or activity, while ignoring the \"unimportant\" details.
None of the above
Question 5.5. (TCO 1) Which of the following would be a more appropriate choice for a method in a Computer class? (Points : 5)
MonitorSize()
Reboot()
ProcessorType()
Keyboard()
Question 6.6. (TCO 2) Which of the following statements is/are true? (Points : 5)
A. A private (helper) method can only be used inside the class. It cannot be called through an object of the class.
B. The programmer can control the scope of a data member of a class using access specifiers.
C. Perhaps the most important consideration when designing a class is identifying the audience, or users, of the class.
All of the above
Only A and C
Question 7.7. (TCO 2) You are given a Shape class that was designed with the concept of a black box in mind. You need to integrate the Shape class into your own code. Which of the following statements are true? (Points : 5)
You need to analyze each method\'s implementation that you plan to use in order to understand it thoroughly.
You need to figure out the inputs and outputs that are associated with the class.
You may have to modify the internal processing to meet the needs of your specific class.
Without a properly constructed UML diagram you cannot be sure how the new class will integrate with your code.
Question 8.8. (TCO 2) Given a private string attribute called homeState, which of the following are proper pseudocode implementations for a getter and a setter?(Points : 5)
string getHomeState(){return homeState }
int setHomeState(string newHomeState){return homeState }
void getHomeState(){return homeState }
void setHomeState (int newHomeState){homeState = newHomeState}
string getHomeState(){return homeState }
void setHomeState (string newHomeState){ homeState = newHomeState}
string getHomeState (){homeState = newHomeState}
void setHomeState (string newHomeState){ homeState = newHomeState}
Question 9.9. (TCO 2) You have been tasked to create an EntertainmentSystem class and your boss wants you to consider the concept of encapsulation as you design your class. Which of the following actions will you take? (Points : 5)
Declare a single no-arg constructor in order to prevent outside entities from initializing the state of a new EntertainmentSystem object.
Combine attributes and behaviors specific to an EntertainmentSystem together into one cohesive unit.
Declare the class as static so that only one instance of an EntertainmentSystem can be used at a time.
Declare the class as private.
All of the above
Question 10.10. (TCO 7) Which of the following statements is false? (Points : 5)
A pure virtual function is a function without function implementation and can be found in an abstract class.
If a derived class extends an abstract base class, the derived class must implement the pure virtual functions declared in the abstract base class.
Any method in an abstract class is considered a pure virtual function.
Pure virtual functions are inherited.
Question 11.11. (TCO 7) What is an abstract class? (Points : 5)
A generalized class used only to create related derived classes
A class without any superclasses
A class from which we create many instances
Any subclass with more than one superclass
Question 12.12. (TCO 7) In terms of object-oriented programming, rules for the use of an application programming interface or framework can be enforced through the use of a(n) _____. (Points : 5)
contract
inheritance hierarchy
has-a relationship
object constructed with a multi-arg constructor
All of the above
Solution
Question 2.2 :-
Which of the following components of a class definition do not have a return type?
Public member methods
Accessor/mutator methods
Constructors - Correct Answer
Private member methods
None of the above
Explanation :-
* Constructor should not contain return type.
Question 3.3 :-
Which of the following method pairs are not examples of method overloading?
public void Dance() ; public int Dance(int x)
public int Walk(int x, int y) ; public void Walk(int x, int y, int z)
public int Jump(int x, int y) ; public int Jump(int y, int x) - Correct Answer
All of the above
Only A and B
Explanation :-
If two methods have same method name, those methods are considered as overloaded methods. Then the rule we should check is both methods must have different parameter types or lists or order. But there is no rule on return type, Non-Accessibility Modifier, and Accessibility Modifier means Overloading method can have its own return type, Non-Accessibility Modifier, and Accessibility Modifier because Overloading methods are different methods.
Question 6.6 :-
Which of the following statements is/are true?
A. A private (helper) method can only be used inside the class. It cannot be called through an object of the class.
B. The programmer can control the scope of a data member of a class using access specifiers.
C. Perhaps the most important consideration when designing a class is identifying the audience, or users, of the class.
All of the above
Only A and C - Correct Answer
Explanation :-
The class members which have private keyword in its creation statement are called private members. Those members are only accessible with in that class.
Question 11.11 :-
What is an abstract class?
A generalized class used only to create related derived classes - Correct Answer
A class without any superclasses
A class from which we create many instances
Any subclass with more than one superclass
Explanation :-
A class that is declared with abstract modifier is called abstract class. Abstract class is a partially implemented class. It will contain both abstract methods and concrete methods. Abstract methods for declaring operations to be implemented by its sub types and Concrete methods for implementing operations common to its next sub types.
Question 12.12 :-
In terms of object-oriented programming, rules for the use of an application programming interface or framework can be enforced through the use of a(n) _____.
contract
inheritance hierarchy - Correct Answer
has-a relationship
object constructed with a multi-arg constructor
All of the above
Explanation :-
In terms of object-oriented programming, rules for the use of an application programming interface or framework can be enforced through the use of an inheritance hierarchy.


