Olete.in
Articles
Mock Tests
🧪 C/C MCQ Quiz Hub
C Programming MCQS Set-1
Choose a topic to test your knowledge and improve your C/C skills
1. Wrapping data and its related functionality into a single entity is known as ____________
Abstraction
Encapsulation
Polymorphism
Modularity
2. How structures and classes in C++ differ?
In Structures, members are public by default whereas, in Classes, they are private by default
In Structures, members are private by default whereas, in Classes, they are public by default
Structures by default hide every member whereas classes do not
Structures cannot have private members whereas classes can have
3. What does polymorphism in OOPs mean?
Concept of allowing overiding of functions
Concept of hiding data
Concept of keeping things in differnt modules/files
Concept of wrapping things into a single unit
4. Which concept allows you to reuse the written code?
Encapsulation
Abstraction
Inheritance
Polymorphism
5. Which of the following explains Polymorphism?
int func(int, int);float func1(float, float);
int func(int); int func(int);
int func(float); float func(int, int, char);
int func(); int new_func();
6. Which of the following shows multiple inheritances?
A->B->C
A->B; A->C
A,B->C
B->A
7. How access specifiers in Class helps in Abstraction?
They does not helps in any way
They allows us to show only required things to outer world
They help in keeping things together
Abstraction concept is not used in classes
8. C++ is ______________
procedural programming language
object oriented programming language
functional programming language
both procedural and object oriented programming language
9. What does modularity mean?
Hiding part of program
Subdividing program into small independent parts
Overriding parts of program
Wrapping things into single unit
10. Which of the following feature of OOPs is not used in the following C++ code? class A { int i; public: void print(){cout<<"hello"<<i;} } class B: public A { int j; public: void assign(int a){j = a;} }
Abstraction
Encapsulation
Inheritance
Polymorphism
11. 1. Which of the following class allows to declare only one object of it?
Abstract class
Virtual class
Singleton class
Friend class
12. 2. Which of the following is not a type of Constructor?
Friend constructor
Copy constructor
Default constructor
Parameterized constructor
13. Which of the following is correct?
Base class pointer object cannot point to a derived class object
Derived class pointer object cannot point to a base class object
A derived class cannot have pointer objects
A base class cannot have pointer objects
14. Out of the following, which is not a member of the class?
Static function
Friend function
Constant function
Virtual function
15. What is the other name used for functions inside a class?
Member variables
Member functions
Class functions
Class variables
16. Which of the following cannot be a friend?
Function
Class
Object
Operator function
17. Why references are different from pointers?
A reference cannot be made null
A reference cannot be changed once initialized
No extra operator is needed for dereferencing of a reference
All of the mentioned
18. Which of the following provides a programmer with the facility of using object of a class inside other classes?
Inheritance
Composition
Abstraction
Encapsulation
19. How many types of polymorphism are there in C++?
1
2
3
4
20. How run-time polymorphisms are implemented in C++?
Using Inheritance
Using Virtual functions
Using Templates
Using Inheritance and Virtual functions
21. How compile-time polymorphisms are implemented in C++?
Using Inheritance
Using Virtual functions
Using Templates
Using Inheritance and Virtual functions
22. Which of the following is an abstract data type?
int
float
class
string
23. Which concept means the addition of new components to a program as it runs?
Data hiding
Dynamic binding
Dynamic loading
Dynamic typing
24. Which of the following explains the overloading of functions?
Virtual polymorphism
Transient polymorphism
Ad-hoc polymorphism
Pseudo polymorphism
25. Which of the following approach is used by C++?
Top-down
Bottom-up
Left-right
Right-left
26. Which operator is overloaded for a cout object?
&gt;&gt;
&lt;&lt;
&lt;
&gt;
27. Which of the following cannot be used with the virtual keyword?
Class
Member functions
Constructors
Destructors
28. Which concept is used to implement late binding?
Virtual functions
Operator functions
Constant functions
Static functions
29. Which of the following is correct?
C++ allows static type checking
C++ allows dynamic type checking.
C++ allows static member function to be of type const.
C++ allows both static and dynamic type checking
30. Which of the following supports the concept that reusability is a desirable feature of a language?
It reduces the testing time
It reduces maintenance cost
It decreases the compilation time
It reduced both testing and maintenance time
31. Which of the following is a static polymorphism mechanism?
Function overloading
Operator overloading
Templates
All of the mentioned
32. Which of the following is true? I) All operators in C++ can be overloaded. II) The basic meaning of an operator can be changed.
I only
II only
Both I and II
Neither I nor II
33. Which of the following is not a type of inheritance?
Multiple
Multilevel
Distributive
Hierarchical
34. What happens if a class does not have a name?
It will not have a constructor
It will not have a destructor
It is not allowed
It will neither have a constructor or destructor
35. Which of the following statement is true? I) In Procedural programming languages, all function calls are resolved at compile-time II) In Object Oriented programming languages, all function calls are resolved at compile-time
I only
I I only
Both I and II
Neither I nor I
36. Which members are inherited but are not accessible in any case?
Private
Public
Protected
Both private and protected
37. Which of the following is correct?
Friend functions can access public members of a class
Friend functions can access protected members of a class
Friend functions can access private members of a class
All of the mentioned
38. Which of the following is correct in C++?
Classes cannot have protected data members
Structures can have member functions
Class members are public by default
Structure members are private by default
39. Which of the following is used to make an abstract class?
By using virtual keyword in front of a class declaration
By using an abstract keyword in front of a class declaration
By declaring a virtual function in a class
By declaring a pure virtual function in a class
40. Which of the following is correct?
A class is an instance of its objects
An object is an instance of its class
A class is an instance of the data type that the class have
An object is an instance of the data type of the class
41. Which of the following is correct about new and malloc?
Both are available in C
Pointer object initialization of a class with both new and malloc calls the constructor of that class
Pointer object initialization of a class using new involves constructor call whereas using malloc does not involve constructor call
Pointer object initialization of a class using malloc involves constructor call whereas using new does not involve constructor call
42. What is virtual inheritance?
C++ technique to avoid multiple copies of the base class into children/derived class
C++ technique to avoid multiple inheritances of classes
C++ technique to enhance multiple inheritance
C++ technique to ensure that a private member of the base class can be accessed somehow
43. What is the difference between delete and delete[] in C++?
delete is used to delete normal objects whereas delete[] is used to pointer objects
delete is a keyword whereas delete[] is an identifier
delete is used to delete single object whereas delete[] is used to multiple(array/pointer of) objects
delete is syntactically correct but delete[] is wrong and hence will give an error if used in any case
44. What will be the output of the following C++ code? #include <iostream> using namespace std; class A{ public: A(){ cout<<"Constructor called "; } ~A(){ cout<<"Destructor called "; } }; int main(int argc, char const *argv[]) { A *a = new A[5]; delete a; return 0; }
Constructor called five times and then Destructor called five times
Constructor called five times and then Destructor called once
Error
Segmentation fault
45. What is the correct syntax of declaring array of pointers of integers of size 10 in C++?
int arr = new int[10];
int **arr = new int*[10];
int *arr = new int[10];
int *arr = new int*[10];
Submit