C++ Aptitude Test

 This post presents a C++ programming aptitude test for beginners with 25 multiple-choice questions.

These beginner-level MCQ questions provide a foundation for understanding basic concepts and syntax of C++ programming, suitable for those new to the language.

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

a) 1variable
b) variable1
c) *variable
d) variable-1

2. What does the following expression return: 5.0 / 2?

a) 2
b) 2.5
c) 2.0
d) 3

3. Which header file is needed to use cout and cin?

a) <string>
b) <iostream>
c) <stdio.h>
d) <ostream>

4. How do you create an integer variable with the initial value 10 in C++?

a) int x = 10;
b) int x(10);
c) Both a) and b)
d) None of the above

5. What is the output of int x = 10; cout << ++x;?

a) 10
b) 11
c) Error
d) None of the above

6. Which keyword is used to create a constant in C++?

a) #define
b) const
c) final
d) Both a) and b)

7. What is the standard return type of the main function in C++?

a) int
b) void
c) double
d) float

8. What is the scope resolution operator in C++?

a) ::
b) ::
c) ::
d) ::

9. What is the use of the new operator?

a) To create a new variable
b) To allocate dynamic memory
c) To check for type compatibility
d) To terminate the program

10. Which of the following is NOT a loop structure in C++?

a) for
b) while
c) loop
d) do-while

11. What is a boolean type in C++?

a) bool
b) boolean
c) int
d) true

12. What is the correct way to refer to the string class in the standard namespace?

a) string
b) std::string
c) Std::string
d) STRING

13. How do you declare a reference variable in C++?

a) int &ref = var;
b) int *ref = &var;
c) ref int = var;
d) int ref = &var;

14. What is the output of int x = 10; cout << x++;?

a) 10
b) 11
c) Error
d) None of the above

15. Which concept allows multiple functions with the same name but different parameters in C++?

a) Overloading
b) Overriding
c) Inheritance
d) Polymorphism

16. What is an object in C++?

a) A type of variable
b) An instance of a class
c) A function
d) A header file

17. Which operator is used to access members of a structure or class using a pointer in C++?

a) .
b) ->
c) &
d) ::

18. Which is the correct way to initialize an array in C++?

a) int arr[3] = {1, 2, 3};
b) int arr() = {1, 2, 3};
c) int arr[] = new int[]{1, 2, 3};
d) int arr = {1, 2, 3};

19. What is encapsulation in C++?

a) Protecting sensitive data from outside interference
b) Breaking a program into various parts
c) Copying the behavior of one object to another
d) None of the above

20. What is inheritance in C++?

a) A process by which one function calls another
b) A class deriving properties and behaviors from another class
c) The ability to call functions without specifying the exact names
d) A way to structure programs using multiple files

21. What does the delete operator do?

a) Deletes variables from the program
b) Frees dynamically allocated memory
c) Removes functions from the program
d) Deletes files from the system

22. What is function overriding in C++?

a) Changing the way functions operate
b) Creating a function with a unique name
c) A subclass providing a specific implementation of a function that is already provided by its superclass
d) Using default function parameters

23. Which of the following is not a visibility mode in C++?

a) public
b) private
c) protected
d) internal

24. How is a class defined in C++?

a) class MyClass {}
b) class MyClass();
c) MyClass {}
d) MyClass();

25. What feature of C++ allows runtime decisions?

a) Compile-time polymorphism
b) Runtime polymorphism
c) Overloading
d) Macros

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top