C++

C++

Test your C++ knowledge with free quizzes on MyCodeSkills covering core concepts.


  1. What is the correct extension of C++ source file?

    • .c
    • .cpp
    • .cp
    • .cxx
  2. Which is the correct output stream in C++?

    • cin
    • cout
    • printf
    • echo
  3. Which header file is required to use cout?

    • stdio.h
    • iostream
    • conio.h
    • stream.h
  4. What is the size of int in C++ (typically)?

    • 2 bytes
    • 4 bytes
    • 8 bytes
    • Depends on system
  5. Which of the following is a correct variable name?

    • 1num
    • num_1
    • %value
    • num-value
  6. What is the purpose of inheritance in C++?

    • Memory management
    • Code reuse
    • Faster execution
    • Data hiding
  7. Which type of inheritance is supported in C++?

    • Single
    • Multiple
    • Multilevel
    • All of the above
  8. Which keyword is used to define a base class?

    • base
    • super
    • class
    • parent
  9. What does polymorphism in C++ refer to?

    • Memory allocation
    • Data hiding
    • Function behavior overloading
    • Inheritance
  10. Which type of function allows polymorphism?

    • Virtual
    • Static
    • Inline
    • Constant
  11. What is the primary purpose of move semantics in C++11 and later?

    • Reduce code size
    • Improve syntax
    • Optimize resource transfers
    • Create inline functions
  12. Which smart pointer shares ownership of an object in C++?

    • unique_ptr
    • auto_ptr
    • raw pointer
    • shared_ptr
  13. What is the output type of a lambda function with no specified return?

    • int
    • void
    • auto
    • Depends on the lambda body
  14. Which header file provides std::thread in C++11?

    • <threading>
    • <concurrency>
    • <thread>
    • <threads>
  15. Which C++ principle ensures proper resource release on exception?

    • OOP
    • STL
    • RAII
    • Inheritance