0% found this document useful (0 votes)
360 views8 pages

C++ MCQ

The document provides a multiple choice quiz on object oriented programming concepts in C++, with 37 questions covering topics like classes, objects, inheritance, polymorphism, arrays, functions, comments and more. Each question is followed by 4 possible answers and the correct answer is indicated. The questions test fundamental concepts as well as syntax used in C++.

Uploaded by

himanshu kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
360 views8 pages

C++ MCQ

The document provides a multiple choice quiz on object oriented programming concepts in C++, with 37 questions covering topics like classes, objects, inheritance, polymorphism, arrays, functions, comments and more. Each question is followed by 4 possible answers and the correct answer is indicated. The questions test fundamental concepts as well as syntax used in C++.

Uploaded by

himanshu kumar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 8

Object Oriented Programming in C++ MCQ With Answer PDF

1. Which of the following is used for implementing the late binding?

1. Operator Functions
2. Virtual Functions
3. Constant Functions
4. All of above

Answer: Virtual Functions

2. Which one of the following cannot be used with the virtual keyword?

1. Destructor
2. Member function
3. Constructor
4. None of the above

Answer: Constructor

3. Which of the following statement is not true about C++?

1. A class cannot have the private members


2. Members of a class are public by default
3. A structure can have the member functions
4. All of the above

Answer: A structure can have the member functions

4. Which of the following is the correct syntax to add the header file in the C++
program?

1. #include "userdefined.h"
2. #include<userdefined>
3. <include> "userdefined.h"
4. Both A & B

Answer: Both A & B

5. Which of the following statements is correct about the friend function in C++
programming language?

1. A friend function can access the private members of a class


2. A friend function is able to access private members of a class
3. A friend function is able to access the public members of a class
4. All of the above

Answer: All of the above

6. Which of the following statements is correct about the class?


1. A class is an instance of its object
2. An object is the instance of the data type of that class
3. An object is an instance of its class
4. All of above

Answer: An object is an instance of its class

7. Which of the following can be used to create an abstract class in the C++
programming language?

1. By using the pure virtual function in the class


2. By declaring a virtual function in the base class
3. By declaring the virtual keyword afterward, the class Declaration
4. None of the above

Answer: By using the pure virtual function in the class

8. Which of the following can be considered as the members that can be inherited but
not accessible in any class?

1. Protected
2. Public
3. Private
4. None of the above

Answer: Private

9. Which of the following is the correct syntax to print the message in C++ language?

1. Out <<"Hello world!;


2. cout <<"Hello world!";
3. Cout << Hello world! ;
4. None of the above

Answer: cout <<"Hello world!";

10. Which of the following can be considered as the correct syntax for declaring an
array of pointers of integers that has a size of 10 in C++?

1. int *arr = new int*[10]


2. int *arr = new int[10];
3. int arr = new int[10];
4. int **arr = new int*[10];

Answer: int **arr = new int*[10];

11. Which one of the following statements correctly refers to the Delete and Delete[] in
C++ programming language?
1. The "Delete" is used for deleting the standard objects, while on the other hand, the
"Delete[]" is used to delete the pointer objects
2. The "Delete" is a type of keyword, whereas the "Delete[]" is a type of identifier
3. The "Delete" is used for deleting a single standard object, whereas the "Delete[]" is
used for deleting an array of the multiple objects
4. Delete is syntactically correct although, if the Delete[] is used, it will obtain an error

Answer: The "Delete" is used for deleting a single standard object, whereas the
"Delete[]" is used for deleting an array of the multiple objects

12. Which of the following statement is correct about Virtual Inheritance?

1. It is a technique to ensure that a private member of a base class can be accessed


2. It is a C++ technique to avoid multiple copies of the base class into the derived or
child classes
3. It is a technique to optimize the multiple inheritances
4. It is a technique to avoid the multiple inheritances of the classes

Answer: It is a C++ technique to avoid multiple copies of the base class into the derived
or child classes

13. Elements of a one-dimensional array are numbered as 0,1,2,3,4,5, and so on; these
numbers are known as ____

1. Members of Array
2. Index values
3. Subscript of Array
4. None of Above

Answer: Both 2 & 3

14. How many types of elements can an array store?

1. Same types of elements


2. Only char types
3. Char and int type
4. All of the above

Answer: Same types of elements

15. Which of the following can be considered as the object of an array?

1. Elements of the Array


2. Index of an array
3. Functions of the Array
4. All of the above

Answer: Elements of the Array

16. Which types of arrays are always considered as linear arrays?


1. Multi-dimensional
2. Single-dimensional
3. All of above
4. None of the above

Answer: Single-dimensional

17. What did we call an array of the one-dimensional array?

1. Multi-Dimensional array
2. Single Dimensional array
3. 2D Array (or 2-Dimensional array)
4. All of above

Answer: 2D Array (or 2-Dimensional array)

18. Which one of the following is the correct definition of the "is_array();" function in
C++?

1. It checks that the specified array of single dimension or not


2. It checks that the array specified of multi-dimension or not
3. It checks that the specified variable is of the array or not
4. All of above

Answer: It checks that the specified variable is of the array or not

19. In C++, for what purpose the "rank()" is used?

1. It returns the maximum number of elements that can be stored in the array
2. It returns the size of each dimension
3. It returns the dimension of the specified array
4. None of the above

Answer: It returns the dimension of the specified array

20. How many types of the array are there in the C++ programming language?

1. In the C++ programming language, there are four types of arrays


2. In the C++ programming language, there are three types of arrays
3. In the C++ programming language, there are two types of arrays
4. All of above

Answer: In the C++ programming language, there are two types of arrays

21. Which of the following is the correct definition of sorting?

1. Sorting information or data only in increasing order


2. Sorting is a type of process in which the data or information is ordered into a specific
order. Example increasing orders, decreasing.
3. Sorting is a type of process in which data elements are modified or manipulated
4. None of the above

Answer: Sorting is a type of process in which the data or information is ordered into a
specific order. Example increasing orders, decreasing.

22. Which type of memory is used by an Array in C++ programming language?

1. None-contiguous
2. Contiguous
3. All of above
4. None of above

Answer: Contiguous

23. Which of the following gives the 4th element of the array?

1. Array[0];
2. Array[0];
3. Array[3];
4. None of the above

Answer: Array[3];

24. Which of the following is the correct syntax for printing the address of the first
element?

1. array[0];
2. array[2];
3. array[1];
4. None of the above

Answer: array[0];

25. Which of the following is the correct identifier?

1. varname@
2. $var_name
3. VAR_123
4. None of the above

Answer: VAR_123

26. Which of the following is the correct syntax for declaring the array?

1. int array [5];


2. init array []
3. Array[5];
4. None of the above

Answer: int array [5];


27. If we stored five elements or data items in an array, what will be the index address
or the index number of the array's last data item?

1. 88
2. 5
3. 4
4. 3

Answer: 4

28. Which of the following is the original creator of the C++ language?

1. Dennis Ritchie
2. Ken Thompson
3. Bjarne Stroustrup
4. Brian Kernighan

Answer: Bjarne Stroustrup

29. The programming language that has the ability to create new data types is
called_______________

1. Overloaded
2. Reprehensible
3. Extensible
4. Encapsulated

Answer: Extensible

30. Which of the following refers to characteristics of an array?

1. An array is a set of distinct data items


2. An array is a set of similar data items
3. An array can hold different types of datatypes
4. None of the above

Answer: An array is a set of similar data items

31. Which of the following features must be supported by any programming language to
become a pure object-oriented programming language?

1. Inheritance
2. Encapsulation
3. Polymorphism
4. All of the above

Answer: All of the above

32. Which one of the following represents the tab?


1. \t
2. \n
3. \r
4. None of the above

Answer: \t

33. Which of the following is the address operator?

1. &
2. #
3. %
4. @

Answer: &

34. Which of the following is the correct syntax to read the single character to console in
the C++ language?

1. get(ch)
2. Scanf(ch)
3. Read ch()
4. Getline vh()

Answer: get(ch)

35. For inserting a new line in C++ program, which one of the following statements can
be used?

1. \r
2. \n
3. \a
4. None of the above

Answer: \n

36. C++ is a ___ type of language.

1. Middle-level language
2. High-level Language
3. Low-level language
4. None of the above

Answer: Middle-level language

37. Which of the following statements is correct about the formal parameters in C++?

1. Parameters which are used in the definition of the function


2. Variables other than passed parameters in a function
3. Variables that are never used in the function
4. Parameters with which functions are called

Answer: Parameters with which functions are called

38. Which of the following comment syntax is correct to create a single-line comment in
the C++ program?

1. /Comment/
2. Comment//
3. //Comment
4. None of the above

Answer: //Comment

39. Which of the following features is required to be supported by the programming


language to become a pure object-oriented programming language?

1. Inheritance
2. Polymorphism
3. Encapsulation
4. All of the above

Answer: All of the above

40. The C++ language is ______ object-oriented language.

1. Not Object oriented


2. Semi Object-oriented or Partial Object-oriented
3. Pure Object oriented
4. None of the above

Answer: Semi Object-oriented or Partial Object-oriented

You might also like