Principles and Programming MCQs > FREE SET - 2

1. Which of the following is used to make an abstract class in C++?
A Declaring it abstract using static keyword.
B Declaring it abstract using virtual keyword.
C Making at least one member function as virtual function.
D Making at least one member function as pure virtual function.

Free MCQs www.sharemcq.com     Answer: Option D
Explanation:
Available Soon.

2. Which of the following access specifier is used as a default in a class definition in C++?
A protected
B public
C private
D friend

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

3. What is correct about the static data member of a class in C++?
A A static member function can access only static data members of a class.
B A static data member is shared among all the object of the class.
C A static data member can be accessed directly from main().
D Both A) and B)

Free MCQs www.sharemcq.com     Answer: Option D
Explanation:
Available Soon.

4. Which of the following provides a reuse mechanism in C++?
A Abstraction
B Inheritance
C Dynamic binding
D Encapsulation

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

5. Which of the following statement is correct in C++?
A Class is an instance of object.
B Object is an instance of a class.
C Class is an instance of data type.
D Object is an instance of data type.

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

6. Which of the following statement is correct regarding destructor of base class in C++?
A Destructor of base class should always be static.
B Destructor of base class should always be virtual.
C Destructor of base class should not be virtual.
D Destructor of base class should always be private.

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

7. How can we make a class abstract in C++?
A By making all member functions constant.
B By making at least one member function as pure virtual function.
C By declaring it abstract using the static keyword.
D By declaring it abstract using the virtual keyword.

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

8. Which of the following statements is correct when a class is inherited publicly in C++?
A Public members of the base class become protected members of derived class.
B Public members of the base class become private members of derived class.
C Private members of the base class become protected members of derived class.
D Public members of the base class become public members of derived class.

Free MCQs www.sharemcq.com     Answer: Option D
Explanation:
Available Soon.

9. Which of the following statements is correct about the C++ constructors and destructors?
A Destructors can take arguments but constructors cannot.
B Constructors can take arguments but destructors cannot.
C Destructors can be overloaded but constructors cannot be overloaded.
D Constructors and destructors can both return a value.

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

10. Which of the following statement is correct in C++ with respect to the use of friend keyword inside a class?
A A private data member can be declared as a friend.
B A class may be declared as a friend.
C An object may be declared as a friend.
D We can use friend keyword as a class name.

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

11. Which of the following keywords is used to control access to a class member in C++?
A Default
B Break
C Protected
D All of the above

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

12. Which of the following can access private data members or member functions of a class in C++?
A Any function in the program.
B All global functions in the program.
C Any member function of that class.
D Only public member functions of that class.

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

13. Which of the following type of data member can be shared by all instances of its class in C++?
A Public
B Inherited
C Static
D Friend

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

14. Which of the following also known as an instance of a class in C++?
A Friend Functions
B Object
C Member Functions
D Member Variables

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

15. Constructor in C++ is executed when
A an object is created
B an object is used
C a class is declared
D an object goes out of scope.

Free MCQs www.sharemcq.com     Answer: Option A
Explanation:
Available Soon.

16. Which of the following statements about virtual base classes in C++ is correct?
A It is used to provide multiple inheritance.
B It is used to avoid multiple copies of base class in derived class.
C It is used to allow multiple copies of base class in a derived class.
D It allows private members of the base class to be inherited in the derived class.

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

17. Which of the following statements is correct in C++?
A Data items in a class must be private.
B Both data and functions can be either private or public.
C Member functions of a class must be private.
D Constructor of a class cannot be private.

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

18. Which of the following can be overloaded in C++?
A Operators
B Functions
C Object
D Both A) and B)

Free MCQs www.sharemcq.com     Answer: Option D
Explanation:
Available Soon.

19. Which of the following is the only technical difference between structures and classes in C++?
A Member function and data are by default protected in structures but private in classes.
B Member function and data are by default private in structures but public in classes.
C Member function and data are by default public in structures but private in classes.
D Member function and data are by default public in structures but protected in classes.

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

20. Which of the following function / type of function cannot be overloaded in C++?
A Member function
B Static function
C Virtual function
D Both A) and B)

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

21. Which of the following function / types of function cannot have default parameters in C++?
A Member function of class
B main()
C Member function of structure
D Both A) and B)

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

22. A constructor that accepts __________ parameters is called the default constructor in C++.
A one
B two
C no
D three

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

23. What happens when a class with parameterized constructors and having no default constructor is used in a program and we create an object that needs a zero-argument constructor in C++?
A Compile-time error.
B Preprocessing error.
C Runtime error.
D Runtime exception.

Free MCQs www.sharemcq.com     Answer: Option A
Explanation:
Available Soon.

24. Destructor has the same name as the constructor in C++ and it is preceded by ______ .
A !
B ?
C ~
D $

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

25. Which constructor function is designed to copy objects of the same class type in C++?
A Create constructor
B Object constructor
C Dynamic constructor
D Copy constructor

Free MCQs www.sharemcq.com     Answer: Option D
Explanation:
Available Soon.

26. When are the Global objects destroyed in C++?
A When the control comes out of the block in which they are being used.
B When the program terminates.
C When the control comes out of the function in which they are being used.
D As soon as local objects die.

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

27. Copy constructor in C++ must receive its arguments by __________ .
A either pass-by-value or pass-by-reference
B only pass-by-value
C only pass-by-reference
D only pass by address

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

28. A function in C++ with the same name as the class, but preceded with a tilde character (~) is called __________ of that class.
A constructor
B destructor
C function
D object

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

29. A union in C++ that has no constructor can be initialized with another union of __________ type.
A different
B same
C virtual
D class

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

30. Which of the following gets called when an object goes out of scope in C++?
A constructor
B destructor
C main
D virtual function

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

31. Which of the following statement is correct in C++?
A Destructor destroys only integer data members of the object.
B Destructor destroys only float data members of the object.
C Destructor destroys only pointer data members of the object.
D Destructor destroys the complete object.

Free MCQs www.sharemcq.com     Answer: Option D
Explanation:
Available Soon.

32. __________ used to make a copy of one class object from another class object of the same class type in C++.
A constructor
B copy constructor
C destructor
D default constructor

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

33. Constructors __________ to allow different approaches of object construction in C++.
A cannot overloaded
B can be overloaded
C can be called
D can be nested

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

34. Which of the following cannot be declared as virtual in C++?
A Constructor
B Destructor
C Data Members
D Both A) and C)

Free MCQs www.sharemcq.com     Answer: Option D
Explanation:
Available Soon.

35. If the copy constructor in C++ receives its arguments by value, the copy constructor would
A call one-argument constructor of the class
B work without any problem
C call itself recursively
D call zero-argument constructor

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

36. It is a __________ error to pass arguments to a destructor in C++.
A logical
B virtual
C syntax
D linker

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

37. If the programmer does not explicitly provide a destructor, then which of the following creates an empty destructor in C++?
A Preprocessor
B Compiler
C Linker
D main()

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

38. A __________ is a constructor that either has no parameters, or if it has parameters, all the parameters have default values in C++.
A Default constructor
B Copy constructor
C Both A and B
D None of these

Free MCQs www.sharemcq.com     Answer: Option A
Explanation:
Available Soon.

39. How many default constructors per class are possible in C++?
A Only one
B Two
C Three
D Unlimited

Free MCQs www.sharemcq.com     Answer: Option A
Explanation:
Available Soon.

40. Which of the following statement is correct about destructors in C++?
A A destructor has void return type.
B A destructor has integer return type.
C A destructor has no return type.
D A destructors return type is always same as that of main().

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

41. Which of the following statement is correct in C++?
A A constructor has the same name as the class in which it is present.
B A constructor has a different name than the class in which it is present.
C A constructor always returns an integer.
D A constructor cannot be overloaded.

Free MCQs www.sharemcq.com     Answer: Option A
Explanation:
Available Soon.

42. Which of the following implicitly creates a default constructor when the programmer does not explicitly define at least one constructor for a class in C++?
A Preprocessor
B Linker
C Loader
D Compiler

Free MCQs www.sharemcq.com     Answer: Option D
Explanation:
Available Soon.

43. Destructor calls are made in which order of the corresponding constructor calls in C++?
A Reverse order
B Forward order
C Depends on how the object is constructed
D Depends on how many objects are constructed

Free MCQs www.sharemcq.com     Answer: Option A
Explanation:
Available Soon.

44. Which of the following never requires any arguments in C++?
A Member function
B Friend function
C Default constructor
D const function

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

45. A class's __________ is called when an object is destroyed in C++.
A Constructor
B Destructor
C Assignment function
D Copy constructor

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

46. Which of the following statements are correct in C++?
A Constructor is always called explicitly.
B Constructor is called either implicitly or explicitly, whereas destructor is always called implicitly.
C Destructor is always called explicitly.
D Constructor and destructor functions are not called at all as they are always inline.

Free MCQs www.sharemcq.com     Answer: Option B
Explanation:
Available Soon.

47. How many times a constructor is called in the life-time of an object in C++?
A Only once
B Twice
C Thrice
D Depends on the way of creation of object

Free MCQs www.sharemcq.com     Answer: Option A
Explanation:
Available Soon.

48. Which of the following gets called when an object is being created in C++?
A Constructor
B Virtual function
C Destructor
D Main

Free MCQs www.sharemcq.com     Answer: Option A
Explanation:
Available Soon.

49. Which of the following statement is correct about constructors in C++?
A A constructor has a return type.
B A constructor cannot contain a function call.
C A constructor has no return type.
D A constructor has a void return type.

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.

50. Which of the following statement is correct whenever an object goes out of scope in C++?
A The default constructor of the object is called.
B The parameterized destructor is called.
C The default destructor of the object is called.
D None of the above.

Free MCQs www.sharemcq.com     Answer: Option C
Explanation:
Available Soon.


No comments:

Post a Comment

Your Feedback is hearty Requested to make the MCQs Collection better.

Popular Posts