Cs304 Quiz 1 solution Fall 2022

 

1. Suppose derived class is inherited from base class. What happens when a derived class object is created?

 

The constructor of base class is executed before the constructor of derived class.

 

 

2. Suppose str1, str2 and str3 are objects of class String. Choose appropriate declaration of overloaded assignment operator for the following statement to work correctly.

str1 = str2 = str3;

 

String& operator =(const String &);

 

 

3. In C++, which of the following is defined as stream insertion operator?

 

<<

 

 

4. Choose correct declaration of overloaded inequality (!=) operator for class String as non-member friend function.

 

None of the given options

 

 

5. Relationship in which child object gets destroyed if parent object is destroyed.

 

Composition

 

 

6. How the information hidden within an object can be accessed?

 

Through its interface

 

 

7. Which of the following defines default constructor for class "Student"?

 

 

Student() {//...

}

 

 

8. The sub-object’s life is not dependent on the life of master class in ___________.

Aggregation

 

 

9. Hiding the implementation details makes program:

 

Easy to understand

 

 

10. The functions defined inside the class are by default ________.

 

Inline

 

 

11. Which of the following statement is TRUE about static function of a class?

 

It is used to access static data members.

 

 

12. Deconstruct is a function which has the same name as that of class but starts with a—– sign

 

~

 

 

13. 'this' pointer cannot be passed implicitly to __________ functions.

 

Static Member

 

 

14. Which of the following can be the behavior of an object “Usman”?

 

Eat

 

 

15. In Object Oriented programming, objects communicate with each other through ________

 

Messages

 

 

16. Constructor is used to______the objects of a class.

 

Initialize

 

 

17. Which of the following is NOT an access specifier in C++?

 

Hidden

 

 

18. The other name of subtyping is ________.

 

Extension

 

19. Suppose a class does not have any constructor. What will happen when an object of this class is created?

 

Compiler will call implicit default constructor.

 

 

20. In case when we define the function outside the class then we must use the keyword _________ to make the function inline.

 

Inline

 

 

21. In constant member function the type of this pointer is:

 

Constant pointer to constant data

 

 

22. In ____________, base class can be replaced by the derived class.

 

Extension

 

 

23. We can get the address of a variable stored in a pointer using __________:

 

& symbol

 

 

24. A child inherits characteristics from its _________.

 

Parent

 

 

25. Which of the following function declaration is correct to overload the + operator as member function in Complex class?

 

Complex operator +(const Complex & rhs);

 

 

26. Which of the following is not true about constant member function?

 

All of the given options

 

 

27. What is the general syntax of overloading Unary Operator as member function of the class?

 

TYPE & operator OP ();

 

 

28. _____ is creating objects of one class inside another class.

 

 

Composition

 

 

29. Which of the following is true about constructor?

 

All of the given option

 

 

30. Memory is allocated to non static members only, when

 

Object is created

 

 

31. A child inherit characteristics from its ?

 

parents

 

 

32. A post-fix unary operator is implemented in C++ member function with

1 dummy int arguments

 

33. Which of the following is the example of objects in school?

Books , pages

 

34. Suppose student is a class, which of the following constructor with one parameter for class student?

 Student()

 

35. If you have three classes in a C++ program A, B, and C where class A inherits from class B, then class ______ contains all the characteristics of class ________.

A, C

 

36. In ____ base class can be replaced by the derived class.

 Extension

 

 

37. The concept of derived class is involved in _____

 

inheritance

 

 

38. Suppose person is a class which of the following statement defines an object of class person?

Create person object

 

39. Which of the following is true about Accessor Functions?

a) They are also used to access private data of the object.

 

b) It can be used to set private data member of the class

c) It can be used to get private data member of the class

d) All of the given options.

 

 

40. The other name of subtyping is

Extension

 

 

 

41. Which of the following statement best describes the constructor

 

constructor is used to initialize the data member of a class.

 

42. Which of the following is true about inline function?

 

It is used by compilers to improve efficiency of the program

 

43. Which of the following is defined as stream extraction operator in c++?

>> 

 

 

44. An object has ___ interface(s)

One or more than one

 

 

45. Which of the following is an advantage of encapsulation?

Better understanding

 

 

46. Which of the following represents the two-way association?

Employee works for the company

 

 

47. ___ is the weakest link between object.

Simple association

 

 

48. Which of the following statement is NOT true about static variable of a class?

 

Static variable belongs to a particular instance of a class

 

 

 

49. In composition ______ are called from composing objects to compound objects.

 

Constructor

 

50. In OOP we can achieve reusability though ______

 

Inheritance

 

51. Generalization is implemented through

 

 Inheritance

 Solution #spring2022 🔻

#cs304quiz1solutionfall2023

#cs304quiz1fall2023

#cs304quizsolutionfall2023

#cs304quiz12023#cs304quiz1solutionfall2023

#cs304qu