Exam 6: Structures and Classes
Exam 1: C++ Basics37 Questions
Exam 2: Flow of Control33 Questions
Exam 3: Function Basics30 Questions
Exam 4: Parameters and Overloading31 Questions
Exam 5: Arrays32 Questions
Exam 6: Structures and Classes37 Questions
Exam 7: Constructors and Other Tools32 Questions
Exam 8: Operator Overloading,friends,and References31 Questions
Exam 9: Strings37 Questions
Exam 10: Pointers and Dynamic Arrays29 Questions
Exam 11: Separate Compilation and Namespaces35 Questions
Exam 12: Streams and File IO43 Questions
Exam 13: Recursion40 Questions
Exam 14: Inheritance30 Questions
Exam 15: Polymorphism and Virtual Functions34 Questions
Exam 16: Templates27 Questions
Exam 17: Linked Data Structures30 Questions
Exam 18: Exception Handling29 Questions
Exam 19: Standard Template Library46 Questions
Exam 20: Patterns and Uml22 Questions
Select questions type
Multiple public: and private: sections are prohibited in a class.
Free
(True/False)
4.8/5
(36)
Correct Answer:
False
C++ allows the programmer to deal with data at a higher level of abstraction in part because related data of differing types can be treated as a unit in
Free
(Multiple Choice)
4.8/5
(40)
Correct Answer:
B,E
What is the reason for separating the interface from the implementation of an ADT?
Free
(Essay)
4.8/5
(36)
Correct Answer:
One obvious benefit is that you can change your client (program that uses the ADT)without requiring that the ADT details be changed.The other benefit is that the ADT author can change the ADT implementation (but not the interface)of the ADT without requiring the client to do anything but relink his code.
The dot operator is used between an object and a data member or between a calling object and a call to a member function from the class of the object.
(True/False)
4.9/5
(41)
Carefully distinguish between the scope resolution operator,and the dot operator.
(Essay)
4.9/5
(39)
A class is a type similar to a structure type that normally has member functions as well as member variables.
(True/False)
4.8/5
(39)
Given the ShoeType structure type-definition.Write a function for the declaration (prototype).
struct ShoeType
{
char style;
double price;
};
void setSalePrice(ShoeType& Item,double discountRate);
//discountRate =(discounted price)/(regular price)
//Adjusts sale price to reflect the specified discount.
(Essay)
4.8/5
(41)
A sure test of whether you have succeeded in producing an Abstract Data Type (whether you have truly separated the interface from the implementation)is whether you can use the ADT then change either the implementation or the client code without being required to change the other.
(True/False)
4.8/5
(43)
Here are several different initializations of a structure variable.State what happens in each initialization.
struct WeatherData
{
int temperature;
int windChill;
int windSpeed;
};
a)WeatherData prediction ={ };
b)WeatherData prediction ={40};
c)WeatherData prediction ={40,-10,};
d)x WeatherData prediction ={40,-10,20 };
(Essay)
4.8/5
(31)
In defining a member function whose declaration is in a class,you use the dot operator to specify that the member function being defined belongs in the class,as
class foo
{
public:
// other members
void output( );
// other members
};
void foo.output( )
{
/* whatever */
}
(True/False)
4.9/5
(32)
A structure member is access using the index operator [ ],with the member name as index.[ ]
(True/False)
4.8/5
(42)
A C++ structure,or struct,like the C++ array,is a homogeneous data structure.(i.e. ,all data is of the same type)
(True/False)
4.7/5
(45)
What is the error in the following structure definition?
struct A
{
int b;
int c;
}
int main()
{
A x;
// other code
}
(Essay)
4.9/5
(38)
Consider the class and struct definitions below.
struct myStruct
{
int i;
double d;
};
class myClass
{
int i;
double d;
};
myStruct a;
a.i = 3;
myClass b;
b.i = 3;
True or False: All these statements will compile with no problem.
(True/False)
4.8/5
(36)
There is no aggregate initialization available for structure variables.You must declare structure variables then use assignment to initialize the members.
(True/False)
4.9/5
(39)
A class type cannot be used in some ways that a built-in type can be used.
(True/False)
4.7/5
(34)
A member of a structure or of a class is accessed using the
(Multiple Choice)
4.7/5
(44)
A structure variable can be defined directly in the same statement that defines a structure definition.
(True/False)
4.9/5
(37)
Showing 1 - 20 of 37
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)