In an object-oriented approach, the most significant (and costly) mistakes are usually those made during the ________ phase. | ||
|
design |
|
testing |
|
construction |
|
analysis |
|
implementation |
OO Concepts, question 1 of 24 |
|
||
In the class diagram above, what are the three sections from top to bottom? | ||
|
Superclass, subclasses, attributes |
|
Data file, methods, subclasses |
|
Class name, attributes, methods |
|
Class name, methods, attributes |
|
Class name, collaborators, subclass methods |
OO Concepts, question 10 of 24 |
Which of the following is an example of a class that is usually distributed to the client at runtime? | ||
|
Web browser |
|
Java applet |
|
Root class |
|
Word processor |
|
Object request broker |
OO Concepts, question 11 of 24 |
|
||||
What thing could logically be represented by class B above? | ||||
|
Petal |
|
Color |
|
Plant |
|
Pollen |
|
Stem |
OO Concepts, question 12 of 24 |
|
||||
Classes often fit into standard design patterns. Which of the following describes the nature of the class shown in the diagram above? | ||||
|
A class for which there can be only one instance in an application |
|
A class that can be used to represent inanimate objects like buildings or cars |
|
An abstract class |
|
A class that must have a superclass |
|
A root class |
OO Concepts, question 13 of 24 |
If an application is written such that when changes are made to class A, many changes are also required in Class B, we say that these classes are highly ________. | ||
|
cohesive |
|
encapsulated |
|
coupled |
|
exclusive |
|
independent |
OO Concepts, question 14 of 24 |
Objects belonging to the same class must share the same ________. | ||
|
methods |
|
children |
|
data values |
|
property values |
|
parents |
OO Concepts, question 15 of 24 |
|
||
Using the class categories above, what types could most likely be purchased from third party vendors? | ||
|
Only system and persistence classes |
|
System, persistence, and some interface classes |
|
Only business and interface classes |
|
Only business and system classes |
|
Only interface classes |
OO Concepts, question 16 of 24 |
In most cases, a benefit of inheritance is that it ________. | ||
|
reduces network traffic |
|
eliminates redundant classes |
|
reduces work |
|
enhances security |
|
increases program execution speed |
OO Concepts, question 17 of 24 |
|
||||
Which statement best describes the relationships shown above? | ||||
|
A person must be part of one or more teams. |
|
Teams are composed of zero or more persons. |
|
Teams are always made up of one or more persons and can include any number of subteams. |
|
Teams always have one or more subteams and zero or more persons. |
|
A team can consist of one or more persons or one or more teams. |
OO Concepts, question 19 of 24 |
|
||
The following methods could logically be defined in abstract class "shape" above EXCEPT ________. | ||
|
fill |
|
draw |
|
setRadius |
|
rotate |
|
scale |
OO Concepts, question 2 of 24 |
A system will model 100 different species. To start, you need a template defining common attributes and methods, though the methods may be implemented differently for each species. What type of class could you create? | ||
|
Persistent |
|
Abstract |
|
Static |
|
Super |
|
Transient |
OO Concepts, question 20 of 24 |
|
||||
To increase maintainability, methods invoked by other methods inside class A should NOT send messages directly to which of the above classes? | ||||
|
Class B only |
|
Class C only |
|
Classes D and E only |
|
Classes C, D, and E only |
|
Classes B, C, D, and E |
OO Concepts, question 21 of 24 |
Which of the following will enhance an application's ability to be maintained? | ||
|
Eliminating abstract classes |
|
Maximizing attributes and methods per class |
|
Mandatory accessor (getter and setter) methods to provide access to attributes |
|
Declaring all attributes as class variables |
|
Minimizing methods per class by making methods longer |
OO Concepts, question 22 of 24 |
Coupling occurs when a change in one class requires changes in other classes. An example of this is _____________. | ||
|
encapsulation |
|
inheritance |
|
overloading methods |
|
many classes |
|
abstraction |
OO Concepts, question 23 of 24 |
|
||
Given the above, in the language of object-oriented programming we would say that class C ________ the interface defined in class B. | ||
|
inherits |
|
overrides |
|
covers |
|
copies |
|
repeats |
OO Concepts, question 24 of 24 |
When developing classes that model business logic that will be stored in a database, it is usually appropriate to ________. | ||
|
define the attributes of the class that will make up the primary key in an abstract class |
|
define the attributes of the class that will make up the primary key as class attributes |
|
use standard classes to create and delete database records, but build update and select statements into the business class |
|
incorporate the basic CRUD (create, retrieve, update, delete) statements in methods within each business class |
|
ensure that the business classes have no knowledge about how they are stored |
OO Concepts, question 3 of 24 |
|
||
Dragons, like the one above, have wings like a bird and scales like a lizard. In object-oriented lingo, we would say that this is an example of ________. | ||
|
inheritance |
|
multiple inheritance |
|
encapsulation |
|
aggregation |
|
polymorphism |
OO Concepts, question 4 of 24 |
Aside from a prototype, what is the next best thing to satisfy a user who really wants to know what an application will be like? | ||
|
A process model |
|
A data-flow diagram |
|
A class-state diagram |
|
A class diagram |
|
A visual storyboard |
OO Concepts, question 5 of 24 |
When designing methods for a class, it is generally preferable to ________. | ||
|
have a few complex methods rather than too many small methods |
|
modify superclass methods directly rather than overriding to accommodate special circumstances |
|
override methods of the superclass even if the superclass version is adequate |
|
have a lot of small concise methods rather than a small number of complex methods |
|
name the methods differently from those of other, similar classes to prevent confusion |
OO Concepts, question 6 of 24 |
Consider splitting a class into several classes when it ________. | ||
|
has more than ten class variables |
|
uses multiple inheritance |
|
has more than two or three subclasses |
|
contains overloaded methods |
|
contains cohesive subsets of related behavior |
OO Concepts, question 7 of 24 |
|
||
What attributes does a class C object contain? | ||
|
Weight |
|
Height, width, and weight |
|
Name, height, width, and weight |
|
Name, idNumber, height, width, and weight |
|
Weight and age |
OO Concepts, question 8 of 24 |
|
||
A state diagram, like the one above, shows how the various methods of an object change its state. This kind of diagram could help you with which of the following? | ||
|
design your data model |
|
understand the relationships between classes |
|
identify and define the methods of a class |
|
identify abstract classes |
|
enforce polymorphism in your design |
OO Concepts, question 9 of 24 |
|
const double *pc; | |
Referring to the code sample above, which of the following statements is true? | ||
|
The value of the object addressed by "pc" can be modified through pc. |
|
The address of the object which contains the value of pc can be modified through "pc". |
|
"pc" can reference an array of double. |
|
"pc" is an array of double objects. |
|
"pc" represents an array of objects of the type float. |
C++, question 1 of 40 |
|
class array {
int a[10]; void check_index(const int index); }; void array::check_index(const int index) { exit(1);} main() { array A; A.check_index(10); } | |
What is wrong with the sample code above? | ||
|
int a[10]; is an incorrect call. The array size must be set using an enum. |
|
"class array" must be defined as "Class Array". |
|
check_index is a friend function, therefore it can only be called by other member functions of the class array. |
|
The object A declared in main() is being called incorrectly. |
|
check_index can only be called by other member functions of the class array. |
C++, question 10 of 40 |
|
class numbers {
int I; public: void set(int v) {I = v;} int read() {return I;} }; | |
Referring to the sample code above, what type of function is set()? | ||
|
A void function |
|
A null function |
|
A member function |
|
A class function |
|
A local function |
C++, question 11 of 40 |
Which set of preprocessor directives is used to prevent multiple inclusions of header files? | ||
|
#ifdefined and #enddefine |
|
#$if and #endif |
|
#define and #endif only |
|
#ifndef, #define and #endif |
|
#if and #define |
C++, question 12 of 40 |
|
class SomeClass
{ const int z = 10; }; | |
What is wrong with the definition of "SomeClass" in the sample code above? | ||
|
It contains no non-const data members. |
|
A const member is initialized in the class definition, and that is not allowed. |
|
Either a default constructor or copy constructor is required, and neither appear in the code above. |
|
It has no access specifier. |
|
It has no constructors. |
C++, question 13 of 40 |
|
class X
{ private: int a; public: X(){cout<<"X constructor was called"<<endl;} ~X(){cout<<"X destructor was called"<<endl;} } ; | |
Referring to the sample code above, what is constructor X() considered to be? | ||
|
A default constructor |
|
Required to be public |
|
A copy constructor |
|
A virtual constructor |
|
Required in a class definition |
C++, question 14 of 40 |
Which of the following defines a class with a static data member and correctly initializes it? | ||
|
class bad {int I=99;};
int bad::I=99; |
|
class bad {static int I = 99;}; |
|
class bad {static I};
int bad:I=99; |
|
class bad {static int I};
int bad::I=99; |
|
class bad {static int I=99;};
int I::bad=99; |
C++, question 15 of 40 |
Which of the following is a C++ mechanism for initializing objects? | ||
|
Constructor |
|
ObjInit |
|
Member functions |
|
InitObj |
|
ObjBuild |
C++, question 16 of 40 |
|
class Tree
{ public: class TreeNode {}; } ; TreeNode *root; | |
What is the error in the sample code above? | ||
|
TreeNode is out of scope. |
|
The scope of Tree is global. |
|
There are no data members declared in the class. |
|
There is no destructor. |
|
There is nothing wrong with the code. |
C++, question 17 of 40 |
|
class Grandpa
{ } ; class Ma : public Grandpa { } ; class Pa : virtual public Grandpa { } ; class Me : public Ma, public Pa, virtual public Grandpa { } ; | |
Each instance of Me will contain how many instances of Grandpa? | ||
|
1 |
|
2 |
|
3 |
|
4 |
|
5 |
C++, question 18 of 40 |
Polymorphism is implemented through which mechanism? | ||
|
Late Binding |
|
Early interpretation |
|
Late interpretation |
|
Early Binding |
|
Early resolution |
C++, question 19 of 40 |
|
class Word
{ public: Word(const char*, int=0); }; | |
Referring to the sample code above, what is the minimum number of arguments required to call the constructor? | ||
|
0 |
|
1 |
|
2 |
|
3 |
|
4 |
C++, question 2 of 40 |
|
int acnt=0;
switch (ch) { case 'a': ++acnt; case 'e': ++acnt; case 'I': ++acnt; } | |
Assuming the value of ch is "a", what will be the value of "acnt" after the block of code is executed? | ||
|
0 |
|
1 |
|
2 |
|
3 |
|
4 |
C++, question 20 of 40 |
|
int main()
{ int *p; int q; p = new int; delete q; return 0 ; } | |
What is wrong with the sample code above? | ||
|
p cannot be initialized to new int since p is an integer pointer. |
|
p has to be declared as a float for this code to work properly. |
|
q cannot be deleted since q is not a pointer. |
|
int q; is an invalid declaration. |
|
p has to be declared as a double for this code to work properly. |
C++, question 21 of 40 |
|
class C
{ int c1, c2; public: C(int a1, int a2) { c1=a1; c2=a2; } } ; | |
Which of the following is equivalent to the constructor shown above? | ||
|
C(int a1, int a2)==c1(a1),c2(a2){} |
|
C(int a1, int a2):c1(a1),c2(a2){} |
|
C{(int a1, int a2)} |
|
C(int a1, int a2)*c1(a1),c2(a2){} |
|
C(int a1, int a2);;c1(a1),c2(a2){} |
C++, question 22 of 40 |
Which of the following statements about function overloading is true? | ||
|
You CANNOT overload a function by creating another function with a different signature. |
|
Function overloading is a mechanism for implementing inheritance in C++. |
|
Function overloading is a mechanism for implementing polymorphism in C++. |
|
You can overload two functions by giving them different names. |
|
You CANNOT overload two functions that have the same signature and name but different return types. |
C++, question 23 of 40 |
|
char *pointer = new char [20] ; | |
Which of the following should you use to free the memory allocated by the statement above? | ||
|
delete pointer ; |
|
delete pointer [20] ; |
|
delete [20] pointer ; |
|
delete [] pointer ; |
|
delete pointer [] ; |
C++, question 24 of 40 |
|
class Golfers
{ public : void Golfers(); void ~Golfers(); }; | |
In the class declaration above, what does "void ~Golfers();" represent? | ||
|
A constructor |
|
A multiple polymorphism |
|
A destructor |
|
A functionoid |
|
A single polymorphism |
C++, question 25 of 40 |
|
switch (category)
{ case 1: percentage_rate = 10.0 ; case 2: percentage_rate = 15.0 ; case 3: percentage_rate = 20.0 ; default: percentage_rate = 25.0 ; } | |
Suppose you wanted to select a percentage rate based upon an integer category. The code fragment found above ________. | ||
|
is incorrect because "case" is not placed before the values. |
|
is incorrect because the case actions need to be enclosed in braces. |
|
will store the same value in percentage_rate no matter what the value of category is. |
|
is incorrect because a select statement should be used instead of switch. |
|
will work in most cases. |
C++, question 26 of 40 |
|
class X
{ private: int a; public: X(){cout<<"X constructor was called"<<endl;} X(int n) {cout<<"X(int) constructor was called"<<endl;} ~X(){cout<<"X destructor was called"<<endl;} }; main() { X x(3); } | |
Which of the following will be the output from the sample above? | ||
|
X constructor was called
X(int) constructor was called X destructor was called |
|
X(int) constructor was called
X destructor was called |
|
X constructor was called
X destructor was called |
|
X constructor was called
X destructor was called |
|
X(int) destructor was called
X destructor was called |
C++, question 27 of 40 |
Where can class member objects be initialized? | ||
|
In an overloaded new operator |
|
In a constructor |
|
In a namespace |
|
In a catch block |
|
In a static initialization block |
C++, question 28 of 40 |
|
string message("a");
string news=message; | |
What does the declaration of "news" do in the sample code above? | ||
|
It calls the default constructor followed by the assignment operator. |
|
It calls the assignment operator only. |
|
It does nothing. The declaration has been incorrectly coded. |
|
It calls the copy constructor only. |
|
It calls the default constructor, assignment operator, and the destructor. |
C++, question 29 of 40 |
If a variable can be modified in a manner that is not defined by the C++ language, you should use which of the following specifiers in the variable declaration? | ||
|
extern |
|
register |
|
volatile |
|
auto |
|
static |
C++, question 3 of 40 |
|
class Color
{ private: float red,white,blue; public: Color(){red=white=blue=0.0;} }; | |
Referring to the sample code above, which of the following will correctly declare a Color object? | ||
|
Color c1(1); |
|
Color c1(red); |
|
Color c1(Color::red); |
|
Color c1(1.00) |
|
Color c1; |
C++, question 30 of 40 |
What is the purpose of a member initialization list? | ||
|
To create objects dynamically. |
|
To assign values to global variables. |
|
To create an array of objects. |
|
To allow arguments to be passed to member constructors. |
|
To reduce memory requirements for programs. |
C++, question 31 of 40 |
|
class mybase {};
class derived1 {}; class derived2:public mybase,derived1{}; | |
Which of the following statements about "derived2" is true in reference to the sample code above? | ||
|
derived2 uses public inheritance for mybase and public inheritance for derived1. |
|
The declaration of "derived2" is invalid because either derived or mybase must be virtual |
|
derived2 uses public inheritance for mybase and private inheritance for derived1. |
|
The declaration of "derived2" is invalid because "derived1" must have an access specifier. |
|
The declaration of "derived2" is invalid because "derived2" can only inherit from one class. |
C++, question 32 of 40 |
|
class Parent
{ } ; class Child : public Parent { } ; Child *c = new Child ; Parent *p = c ; | |
What does the assignment statement above need in order to be legal? | ||
|
A cast operator to Parent defined for Child. |
|
A dynamic_cast from Child to Parent. |
|
A static_cast from Child to Parent. |
|
(Parent *) to cast the pointer c. |
|
Nothing. |
C++, question 33 of 40 |
When does dynamic binding occur? | ||
|
During linking. |
|
During construction. |
|
During execution. |
|
During compilation. |
|
During encapsulation. |
C++, question 34 of 40 |
|
class myclass {
public: myclass(int x); }; myclass::myclass(int x) { a=x;} int main() { myclass ob(120); myclass *p; return 0; } | |
Referring to the sample code above, which of the following would you use to initialize the value of p to the address of the object ob? | ||
|
p=ob; |
|
p=*ob; |
|
*p=*ob; |
|
p=&ob; |
|
*p=myclass *ob; |
C++, question 35 of 40 |
|
class myclass
{ int a, b; public: myclass(int n, int m) {a=n, b=m;} } | |
What is the constructor definition in the sample code above equivalent to? | ||
|
myclass() {a=m, b=n;} |
|
myclass(int n, int m) {a=n+m, b=m+n;} |
|
myclass(int n, int m) {a=m, b=n;{this->a=n,this->b=m;}} |
|
myclass(int n,int m) {this->a=n,this->b=m;} |
|
myclass() {this->a=n,this->b=m;} {a=0, b=0;} |
C++, question 36 of 40 |
|
class ci {
int I; public: ci (int j) {I=j;} ci (ci &rv) { I=rv.I;} }; main() { ci original(1); ci x1(original); ci x2 = original; } | |
Referring to the sample code above, what initializes the object x1? | ||
|
Bitwise copying. |
|
A cast. |
|
The default constructor. |
|
The copy constructor. |
|
The default copy constructor. |
C++, question 37 of 40 |
|
class professor {};
class teacher : public virtual professor {}; class researcher : public virtual professor {}; class myprofessor : public teacher, public researcher {}; | |
Referring to the sample code above, if an object of class "myprofessor" were created, how many instances of professor will it contain? | ||
|
0 |
|
1 |
|
2 |
|
3 |
|
4 |
C++, question 38 of 40 |
|
class Stock_trader
{ int Stock_trader(); }; | |
What is wrong with the class Stock_trader declaration in the sample code above? | ||
|
It has no access specifiers. |
|
Constructors have to be declared as protected. |
|
The closing braces "}" appear too early in the class declaration. |
|
Constructors cannot have return values. |
|
The scope resolution operator has not been utilized in the class declaration. |
C++, question 39 of 40 |
|
class tailor : public virtual worker
{ /*..*/ }; | |
Referring to the sample code above, which of the following statements is true? | ||
|
"worker" and "tailor" are protected virtually. |
|
"worker" and "tailor" are public to each other. |
|
"worker" is a virtual base class of "tailor" |
|
"tailor" is a virtual member of the class "worker". |
|
"tailor" is a base class for a virtual "worker". |
C++, question 4 of 40 |
|
class SomeClass
{ int x ; public: SomeClass (int xx) : x(xx) {} ; } ; SomeClass x (10) ; SomeClass y(x) ; | |
What is wrong with the initialization of y in the sample code above? | ||
|
It is illegal because SomeClass has no public copy constructor. |
|
There is nothing wrong with the initialization of y. It is perfectly legal. |
|
It is illegal because SomeClass has no default constructor. |
|
It is illegal because SomeClass has no copy constructor. |
|
It is illegal because SomeClass has no virtual destructor. |
C++, question 40 of 40 |