A preview of what's in this quiz. Answer them interactively for instant scoring and full explanations.
What is the return type of the mandatory `main` function in C++?
1. What is the return type of the mandatory `main` function in C++?
- A.void
- B.int
- C.double
- D.char
How do you start a single-line comment in C++?
2. How do you start a single-line comment in C++?
- A.# This is a comment
- B.// This is a comment
- C./* This is a comment
- D.<!-- This is a comment -->
Which operator is the stream extraction operator, used with `std::cin` to read input?
3. Which operator is the stream extraction operator, used with `std::cin` to read input?
How do you start a multi-line block comment in C++?
4. How do you start a multi-line block comment in C++?
- A.// comment //
- B./* comment */
- C.{- comment -}
- D.<!-- comment -->
What is the purpose of `std::endl` in output streams?
5. What is the purpose of `std::endl` in output streams?
- A.Ends the main function execution.
- B.Inserts a newline character and flushes the output buffer.
- C.Clears all variables from stack memory.
- D.Checks for stream errors.
Which of the following is correct regarding C++ compilation phases order?
6. Which of the following is correct regarding C++ compilation phases order?
- A.Linker -> Preprocessor -> Compiler -> Assembler
- B.Preprocessor -> Compiler -> Assembler -> Linker
- C.Compiler -> Assembler -> Linker -> Preprocessor
- D.Assembler -> Compiler -> Linker -> Preprocessor
Which operator is the stream insertion operator, used with `std::cout` to print output?
7. Which operator is the stream insertion operator, used with `std::cout` to print output?
What is the dereference operator, used to access the value stored at a pointer's memory address?
8. What is the dereference operator, used to access the value stored at a pointer's memory address?
What is the address-of operator, used to get the memory address of a variable?
9. What is the address-of operator, used to get the memory address of a variable?
What is the size of a standard `bool` variable in C++?
10. What is the size of a standard `bool` variable in C++?
- A.1 bit
- B.1 byte
- C.4 bytes
- D.2 bytes
What is a Destructor in a C++ class?
11. What is a Destructor in a C++ class?
- A.A method deleting variable definitions from compiling lists.
- B.A method prefixed with `~` that cleans up resources before object destruction.
- C.A static method initializing class fields.
- D.A function that throws exceptions.
What is the default access modifier of members declared inside a C++ `struct`?
12. What is the default access modifier of members declared inside a C++ `struct`?
- A.private
- B.public
- C.protected
- D.internal
What is a Reference in C++?
13. What is a Reference in C++?
- A.A pointer that can point to different addresses.
- B.An alias for an existing variable that cannot be null or rebound.
- C.A class instance stored in heap memory.
- D.A compiler validation check.
What is the default access modifier of members declared inside a C++ `class`?
14. What is the default access modifier of members declared inside a C++ `class`?
- A.public
- B.private
- C.protected
- D.package-private
What is the difference between Pass-by-Value and Pass-by-Reference in function parameters?
15. What is the difference between Pass-by-Value and Pass-by-Reference in function parameters?
- A.Pass-by-reference copies data; Pass-by-value does not.
- B.Pass-by-value copies data; Pass-by-reference works on the original variable.
- C.Pass-by-value is only for pointers; Pass-by-reference is for objects.
- D.There is no difference in memory handling.
Which header file must be included to use `std::cout` and `std::cin`?
16. Which header file must be included to use `std::cout` and `std::cin`?
- A.#include <stdio.h>
- B.#include <iostream>
- C.#include <stream>
- D.#include <string>
Which header file must be included to use the standard C++ string class `std::string`?
17. Which header file must be included to use the standard C++ string class `std::string`?
- A.#include <cstring>
- B.#include <string>
- C.#include <iostream>
- D.#include <string.h>
What is the scope resolution operator in C++?
18. What is the scope resolution operator in C++?
What is the member access operator used on object pointers (e.g. `ptr->member`)?
19. What is the member access operator used on object pointers (e.g. `ptr->member`)?
- A.. (used on object references directly)
- B.->
- C.::
- D.*
What is a memory leak in C++?
20. What is a memory leak in C++?
- A.Stack memory overflowing during recursive calls.
- B.Allocating heap memory but failing to deallocate it before losing references.
- C.Accessing out-of-bounds indices in arrays.
- D.Writing binary data to locked files.
Looking for a different topic? Browse all subjects