CS304P Solved Quiz by Munir

CS304P Solved Quiz  by Munir


Question #1:

A class defines the `cout` and stream insertion operator, is called:

Select the correct option.

a) kstream

b) istream

c) ostream

d) fstream

Correct answer: c) ostream


Question #2:

Which of the following is used to get data from the console?

Select the correct option.

a) Stream Extraction operator

b) Operator Overloading

c) Stream Insertion operator

d) Binary Operators

Correct answer: a) Stream Extraction operator


Question #3:

Which of the following operator overloading declaration can be used for pre-increment operators implemented as a member function of the class Complex?

Select the correct option.

a) Complex && operator ++ ();

b) Complex & operator ++ ();

c) None of the given options

d) Complex & Complex::operator++();

Correct answer: d) Complex & Complex::operator++();


Question #4:

Following code is equivalent to which option:

```cpp

class Shape {

    string type;

};

```

Select the correct option.

a) class Shape public: { string type; };

b) class Shape { public: string type; };

c) class Shape { private: string type; };

d) class Shape { protected: string type; };

Correct answer: b) class Shape { public: string type; };


Question #5:

Which of the following is the insertion operator?

Select the correct option.

a) >>

b) <<

c) v

d) ^

Correct answer: b) <<



CS304P Solved Quiz by Munir

Option 1:

Question: Which of the following is the correct way of declaring the attribute as public?

Option: class public Student { char *name; };

Answer: Incorrect


Option 2:

Question: Which of the following is the correct way of declaring the attribute as public?

Option: class Student { char *name; };

Answer: Incorrect


Option 3:

Question: Which of the following is the correct way of declaring the attribute as public?

Option: class Student public: { char *name; };

Answer: Incorrect


Option 4:

Question: Which of the following is the correct way of declaring the attribute as public?

Option: class Student { public: char *name; };

Answer: Correct


Option 1:

Question: Which of the following is the default access specifier for members of a class?

Option: protected and public

Answer: Incorrect


Option 2:

Question: Which of the following is the default access specifier for members of a class?

Option: protected and private

Answer: Incorrect


Option 3:

Question: Which of the following is the default access specifier for members of a class?

Option: private

Answer: Correct


Option 4:

Question: Which of the following is the default access specifier for members of a class?

Option: public

Answer: Incorrect


Option 1:

Question: Which of the given options is not correct for a destructor?

Option: Destructor is a function with the same name as that of class but preceded with a tilde ~

Answer: Correct


Option 2:

Question: Which of the given options is not correct for a destructor?

Option: Destructor is used to free the memory allocated through dynamic allocation.

Answer: Incorrect


Option 3:

Question: Which of the given options is not correct for a destructor?

Option: Destructor is a function with the same name as that of the class, but preceded with a tilde 'void ~'

Answer: Incorrect


Option 4:

Question: Which of the given options is not correct for a destructor?

Option: Destructor is used to free the memory allocated through the new operator.

Answer: Incorrect


Option 1:

Question: Which of the following is represented in the suppressed form of a class?

Option: Attributes

Answer: Incorrect


Option 2:

Question: Which of the following is represented in the suppressed form of a class?

Option: Class Name

Answer: Incorrect


Option 3:

Question: Which of the following is represented in the suppressed form of a class?

Option: Operations

Answer: Incorrect


Option 4:

Question: Which of the following is represented in the suppressed form of a class?

Option: Data

Answer: Correct