[go: up one dir, main page]

0% found this document useful (0 votes)
22 views12 pages

C++ MCQ

The document contains multiple-choice questions (MCQs) related to Object Oriented Programming in C++ for I BCOM ISM for the academic year 2024-2025. It covers fundamental concepts of OOP, syntax, data types, and various programming constructs in C++. Each question is followed by the correct answer, providing a comprehensive review of key topics in C++.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views12 pages

C++ MCQ

The document contains multiple-choice questions (MCQs) related to Object Oriented Programming in C++ for I BCOM ISM for the academic year 2024-2025. It covers fundamental concepts of OOP, syntax, data types, and various programming constructs in C++. Each question is followed by the correct answer, providing a comprehensive review of key topics in C++.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

MCQ Questions - Object Oriented Programming in C++ - I BCOM ISM -

2024-2025

1. Which of the following is not a basic concept of OOP?

A) Encapsulation

B) Polymorphism

C) Overloading

D) Tokenization

Answer: D) Tokenization

2. Which benefit of OOP allows for code reusability?

A) Encapsulation

B) Inheritance

C) Abstraction

D) Polymorphism

Answer: B) Inheritance

3. Which of the following is a token in C++?

A) Keyword

B) Identifier

C) Constant

D) All of the above

Answer: D) All of the above

4. In C++, which of the following is used to define a variable?

A) Data type

B) Operator

C) Function
D) Class

Answer: A) Data type

5. Which operator is used to access members of a class in C++?

A) .

B) ::

C) ->

D) *

Answer: A) .

6. What is function prototyping in C++?

A) Declaring a function after its definition

B) Declaring a function before its definition

C) Defining a function

D) Calling a function

Answer: B) Declaring a function before its definition

7. What does an inline function do?

A) It reduces function call overhead

B) It increases function call overhead

C) It is always virtual

D) It cannot return values

Answer: A) It reduces function call overhead

8. Which of the following is true about friend functions?

A) They are members of a class

B) They can access private and protected members of a class

C) They are always inline


D) They cannot be overloaded

Answer: B) They can access private and protected members of a class

9. What is the return type of a constructor in C++?

A) int

B) void

C) class name

D) No return type

Answer: D) No return type

10. Virtual functions are used to achieve:

A) Function Overloading

B) Operator Overloading

C) Polymorphism

D) Encapsulation

Answer: C) Polymorphism

11. Which of the following correctly initializes an array in C++?

A) int arr[5] = {1, 2, 3};

B) int arr() = {1, 2, 3};

C) int arr[5] = [1, 2, 3];

D) int arr[5] = {1, 2, 3, 4, 5};

Answer: D) int arr[5] = {1, 2, 3, 4, 5};

12. What does the following statement do: int *ptr = &x;

A) Declares a pointer and assigns it the address of x

B) Declares a pointer and assigns it the value of x


C) Declares an integer variable and assigns it the value of x

D) Declares an integer variable and assigns it the address of x

Answer: A) Declares a pointer and assigns it the address of x

13. Which pointer is used to access the object that invokes a member function?

A) This pointer

B) Null pointer

C) Object pointer

D) Member pointer

Answer: A) This pointer

14. What is the keyword used to define a class in C++?

A) class

B) struct

C) object

D) private

Answer: A) class

15. How do you define an object of a class named "Student"?

A) Student obj;

B) obj Student;

C) class Student obj;

D) Student class obj;

Answer: A) Student obj;

16. What is the purpose of a constructor?

A) To deallocate memory
B) To initialize objects

C) To create a function

D) To access private members

Answer: B) To initialize objects

17. Which of the following is true about destructors?

A) They have the same name as the class

B) They have no parameters

C) They are called automatically when an object is destroyed

D) All of the above

Answer: D) All of the above

18. Which type of constructor can be called with no arguments?

A) Default constructor

B) Parameterized constructor

C) Copy constructor

D) Dynamic constructor

Answer: A) Default constructor

19. Which concept allows functions with the same name but different parameters?

A) Polymorphism

B) Inheritance

C) Encapsulation

D) Function Overloading

Answer: D) Function Overloading

20. How do you differentiate between overloaded functions?

A) By return type
B) By function name

C) By parameters

D) By access specifiers

Answer: C) By parameters

21. What is operator overloading?

A) Defining new operators

B) Using operators on more than one type

C) Redefining existing operators for user-defined types

D) Using operators as function arguments

Answer: C) Redefining existing operators for user-defined types

22. Which of the following is true about inheritance in C++?

A) It allows one class to inherit the properties of another class

B) It restricts code reusability

C) It cannot be used with classes

D) It does not support polymorphism

Answer: A) It allows one class to inherit the properties of another class

23. What is the correct syntax for single inheritance in C++?

A) class Derived: public Base {}

B) class Derived: Base {}

C) class Derived(Base) {}

D) class Derived -> Base {}

Answer: A) class Derived: public Base {}

24. Which type of inheritance allows a class to inherit from multiple classes?
A) Single inheritance

B) Multiple inheritance

C) Multilevel inheritance

D) Hierarchical inheritance

Answer: B) Multiple inheritance

25. Which function is called when an object is destroyed?

A) Destructor

B) Constructor

C) Member function

D) Virtual function

Answer: A) Destructor

26. Which of the following is not a control structure in C++?

A) if-else

B) for

C) while

D) class

Answer: D) class

27. What keyword is used to declare a constant in C++?

A) static

B) final

C) const

D) let

Answer: C) const
28. Which operator is used for input in C++?

A) >>

B) <<

C) ==

D) //

Answer: A) >>

29. What is the extension of a C++ source file?

A) .c

B) .cpp

C) .cs

D) .java

Answer: B) .cpp

30. Which access specifier allows members of a class to be accessed from outside?

A) private

B) protected

C) public

D) default

Answer: C) public

31. Which of the following is a correct way to declare a reference variable in C++?

A) int &ref = var;

B) int ref = &var;

C) int *ref = var;

D) int ref = *var;

Answer: A) int &ref = var;


32. What does "this" pointer point to in a member function?

A) The function itself

B) The object that called the function

C) The class of the object

D) The base class

Answer: B) The object that called the function

33. Which of the following is a manipulator in C++?

A) cin

B) cout

C) endl

D) printf

Answer: C

34..What is the output of the following code ?

#include <iostream>

using namespace std;


int main() {
int x = 5;
cout << x++ << ++x << x;
return 0;
}

Answer : 5 7 7

35.Which of the following is not a valid C++ identifier?

a) _myvar
b) 1stvar
c) My_var

Answer:b

36. What is the output of the following code ?


#include <iostream>
using namespace std;
int main()
{
int x = 10;
int y = 20;
int z = x + y;
cout << "The sum of " << x << " and " << y << " is " << z ;
return 0;
}

Answer : The sum of 10 and 20 is 30

37. Which of the following is a correct way to declare a pointer?

Answer: int * p;

38. Identify the correct extension of the user-defined header file in C++.

Answer: .h

39.Identify the incorrect constructor type.

Answer:Friend Constructor

40. C++ uses which approach?

Answer: bottom-up

41.Which of the following data type is supported in C++ but not in C?

Answer:bool

42.Identify the correct syntax for declaring arrays in C++.

Answer: int arr[10]

43.Which of the following is “address of operator”?.

Answer: &

44.Which OOP concept involves hiding the internal details of an object?

A) Encapsulation

B) Inheritance

C) Polymorphism

D) Abstraction
Answer: A) Encapsulation

45.Which C++ keyword is used to define a constant value?

A) constant

B) static

C) const

D) #define

Answer: C) const

46. Which operator is used for dereferencing a pointer in C++?

A) *

B) &

C) ->

D) ::

**Answer: A) ***

47. Which of the following is not a type of C++ loop?

A) for

B) while

C) until

D) do-while

Answer: C) until

48. What is the purpose of the 'sizeof' operator in C++?

A) To return the size of a data type or object

B) To allocate memory

C) To perform arithmetic operations

D) To compare two values


Answer: A) To return the size of a data type or object

49.What is the return type of a destructor in C++?

A) int

B) void

C) class name

D) No return type

Answer: D) No return type

50.What is the default access specifier for class members in C++?

A) public

B) private

C) protected

D) static

Answer: B) private

You might also like