Which of the following would be a more appropriate choice


1. Which of the following would be a more appropriate choice for a method in a PhoneCharger class?

Voltage

Manufacturer

Current

Charge

Question 2.Object-oriented programming generally focuses on _____.

A. separating the interface from the implementation.

B. client side access to implementation details.

C. creating as many classes as possible.

D. code reuse with methods.

All of the above

None of the above

Only A, B, and D

Question 3. Which of the following components of a class definition do not have an access modifier?

State variables

Data members

Member methods

Destructor

None of the above

Question 4. Which of the following statements is/are true?

A. In general, reusable classes tend to have interfaces that are more abstract than concrete.

B. The compiler generated default constructor does the exact same job as any user defined default constructor

C. A private (helper) method is part of a class's interface

None of the above

Only A and B

Question 5. Which of the following method pairs are not examples of method overloading?

public void Bake() ; public int Bake()

public int Mix(int x, int y) ; public int Mix(int y, int x)

public int Shake(int x, int y) ; public int Shake(int x, int y, int z)

None of the above

Only A and B

Question 6. Which of the following statements is/are false?

Abstraction is the process of ignoring the high level information about a category entity or activity, while concentrating on the "unimportant" details.

The object-oriented paradigm permits the modeling of a software system in a more natural way compared to the procedural paradigm.

In object-oriented programming, we design the program as a set of cooperating objects.

None of the above

Question 7. You have been tasked to create an Automobile 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?

Declare as many class attributes public as you can, creating accessor/mutators for each one.

Package attributes and behaviors specific to an Automobile together.

Make sure to include a specific implementation for a drive method that all subclasses can inherit.

Declare the class as private.

All of the above

Question 8.A black box is a term used to describe a system that can be understood solely based on its inputs, a description of its _____ and the resulting outputs.

processing

inherited processes

attributes

accessors

Question 9. A class is designed with two public attributes: attributeOne and attributeTwo. attributeOne is an integer data type while attributeTwo is a string data type. Which pseudocode representation(s) of setters would be appropriate for this class?

int setAttributeOne(int newAttributeOne)

{

return attributeOne

}

void setAttributeOne(int newAttributeOne)

{

attributeOne = newAttributeOne

}

string setAttributeTwo (int newAttributeTwo)

{

attributeTwo = newAttributeTwo

}

void setAttributeTwo ()

{

attributeTwo = " "

}

Both A and C

None of the above

Question 10. How is the pure virtual function different from a regular function?

It can only be declared in an abstract class.

It is declared with =0 at the end of the function signature.

It does not contain function implementation.

All of the above

Question 11. A(n) _____ cannot be instantiated and therefore is used only to form related derived classes.

method

abstract method

class

abstract class

Question 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

has-a relationship

object constructed with a multi-arg constructor

All of the above

13.If you have a complete, working Box class that has been thoroughly tested, and you wish to add an overloaded displayVolume() method that can display the location and volume of a GraphicBox, how should this be accomplished?

Derive a new GraphicBox class from the first Box class.

Add the method to your existing Box class.

Make a brand new class.

Add the method in the same class as the main.

Question 14. An Order class and RushOrder class have what type of relationships?

The Order has-a RushOrder.

The Order is-a RushOrder.

The RushOrder has-an Order.

The RushOrder is-an Order.

Question 15. Why might it be better to create a derived class instead of adding a few lines of code to an existing Class?

Simplifies testing

No need to re-test the previously written class

Saves time on debugging the program

All of the above

None of the above

Question 16. Suppose class Child is derived from class Parent which in turn is derived from class GrandParent. When we destroy an object of class Child, three destructors are called: i) Child, ii) Parent, iii) GrandParent. What is the order?

Child, Parent, GrandParent

Parent, GrandParent, Child

GrandParent, Child, Parent

GrandParent, Parent, Child

Question 17.The ability to reuse objects already defined, perhaps for a different purpose, with modification appropriate to the new purpose, is referred to as _____.

information hiding.

inheritance.

redefinition.

overloading

Question 18. Which of the following is not a good example of a hierarchy that could be modeled with inheritance?

Airplanes

Geometric shapes

Animals

Prime numbers

Question 19. Examine the class definition. How many members does it contain?

class clockType

{

public:

void setTime(int, int, int);

void getTime()const;

void printTime() const;

void icrementSeconds();

void incrementMinutes();

void incrementHours();

bool equalTime(const clockType&) const;

private:

int hr;

int min;

int sec;

};

7

3

5

10

Question 20. Which of the following declares a pure virtual function in an abstract C++ class?

public void cookIngredients() {}

public void cookIngredients()

public void cookIngredients()=0;

public cookIngredients();

Question 21.Suppose that bClass is a class. Which of the following statements correctly derives the class dClass from bClass?

class dClass:: public bClass

{

//classMembersList

};

class dClass: private bClass

{

//classMembersList

};

class dClass:: protected bClass

{

//classMembersList

};

class bClass: public dClass

{

//classMembersList

};

Question 22. Data/information hiding and encapsulation improves construction and maintenance because: adding additional details is isolated to a single class.

program bugs are isolated to a single class.

programming to an interface makes the code more logical.

All of the above

None of the above

Question 23. What are some of the characteristics of a "good" comment?

Summary comments that distill the logic of an algorithm

Comments are well-written and clear

Comments showing the intent of the code

All of the above

None of the above

Question 24. The purpose of a namespace is to:

organize your code.

gives you a way to create global types.

provide a container for logically related items.

All of the above

None of the above

ESSAY QUESTIONS

Briefly describe which elements of a class use the Camel case, and what are the best practices regarding the naming of these elements.

Question 1. Provide an example that shows how we can have Encapsulation without Data/Information Hiding in object-oriented programming.

Question 2. Given the following program description,

• identify the required classes/objects necessary to achieve the program requirements;

• briefly describe any relationships that might exist between your classes; and

• briefly describe the overall hierarchy of your proposed classes.

Program Description - You have been asked to create a program designed to keep track of the inventory in a person's house. The program must keep track of all items owned by the house's resident and their specific location in the house. A single room can contain any number of items and every item should have a unique ID to differentiate it from all the other items.

Question 3. How are pure virtual functions created? When a class contains one pure virtual function, what will happen? Can we still treat the class like a normal class?

Question 4. Consider the class Bicycle. Given your knowledge of some common components of bicycles

• show a class hierarchy in which the class Bicycle inherits from other classes, which, in turn, can also be inherited from yet other classes;

• discuss inheritance from class Bicycle for other closely related derived classes; and

• discuss the common components of class Bicycle.

Question 5. How does the "has-a" relationship relate to composition? Give an example of such a relationship.

Question 6. Define and implement the overloaded constructors that support the following test function for a StudentEmployee class. The data members for the StudentEmployee class are:

• age - integer number

• name - String

• DSI - String

• salary - floating point number

int main()

{ //s1 will take all default value

StudentEmployee s1();

//s2 will take all supplied values

StudentEmployee s2 (50, "Jackie Chan", "D87654321", 10000000.99);

//s3 will take supplied age value, name, DSI and salary will take default values

StudentEmployee s3 (25);

//s4 will take supplied age and name value, DSI and salary will take default values

StudentEmployee s4 (35, "Jenny");

//s5 will take supplied age, name and DSI value, salary will take default value

StudentEmployee s5 (45, "Jack", "D11223344");

//s6 will take supplied age, name and salary value, DSI will take default value

StudentEmployee s6 (60, "James Bond", 65000.0);

//s7 will take the same value of s2

StudentEmployee s7=s2;

//the rest of the code

}

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Which of the following would be a more appropriate choice
Reference No:- TGS01032152

Expected delivery within 24 Hours