C++ Basics MCQs | C++ प्रोग्रामिंग के Multiple Choice Questions (Beginners के लिए) – MCQ Question Paper with Answers

C++ Basics MCQs का बेहतरीन संग्रह। शुरुआती छात्रों के लिए C++ प्रोग्रामिंग के महत्वपूर्ण बहुविकल्पीय प्रश्न, जो परीक्षा, अभ्यास और इंटरव्यू की तैयारी में मददगार हैं।

All questions are curated for practice and learning purposes.Suitable for competitive exams, interviews, and self-study.

This MCQ question paper is designed for students, job aspirants, and professionals who want to practice Hindi Quiz questions at their own pace. Answers are available for self-evaluation.

Published: • Updated:

Share this quiz

Invite friends to practice, compare scores, or save this page.

MCQ Questions

50 questions
  1. 1. C++ में RAII का पूरा नाम क्या है और यह किस सिद्धांत पर आधारित है?

    • AResource Allocation Is Initialization
    • BResource Acquisition Is Initialization
    • CRuntime Allocation In Inheritance
    • DResource Access In Interface
    Show Correct Answer
    Explanation RAII (Resource Acquisition Is Initialization) C++ का मूल सिद्धांत है। यह constructor में resource acquire करता है और destructor में release करता है, जिससे exception safety सुनिश्चित होती है।
  2. 2. unique_ptr और shared_ptr में मुख्य अंतर क्या है?

    • Aunique_ptr की copy बनाई जा सकती है
    • Bshared_ptr exclusive ownership रखता है
    • Cunique_ptr केवल एक owner रखता है, जबकि shared_ptr कई owners को allow करता है
    • Dदोनों same reference counting इस्तेमाल करते हैं
    Show Correct Answer
    Explanation unique_ptr exclusive ownership देता है (move-only), shared_ptr shared ownership देता है reference counting के साथ।
  3. 3. Move semantics C++ में किस version में introduce हुए?

    • AC++98
    • BC++03
    • CC++11
    • DC++14
    Show Correct Answer
    Explanation Move semantics C++11 में rvalue references (&&) के साथ आए, जो unnecessary copying से बचाते हैं।
  4. 4. std::move() function का असली काम क्या है?

    • AObject को physically move करता है
    • BObject को rvalue reference में cast करता है
    • CMemory copy करता है
    • DObject को delete कर देता है
    Show Correct Answer
    Explanation std::move() सिर्फ casting करता है ताकि move constructor या assignment operator call हो सके। असली move compiler perform करता है।
  5. 5. Rvalue reference का syntax क्या होता है?

    • A&
    • B&&
    • C*&
    • Dconst&
    Show Correct Answer
    Explanation T&& rvalue reference बनाता है जो temporary objects या std::move() से आए values को bind करता है।
  6. 6. Smart pointers किस header में define होते हैं?

    • A<iostream>
    • B<memory>
    • C<vector>
    • D<string>
    Show Correct Answer
    Explanation unique_ptr, shared_ptr और weak_ptr <memory> header में उपलब्ध हैं।
  7. 7. weak_ptr का मुख्य उपयोग क्या है?

    • AMemory allocate करना
    • BReference cycle break करना
    • CObject copy करना
    • DPointer delete करना
    Show Correct Answer
    Explanation weak_ptr shared_ptr के साथ मिलकर circular reference (memory leak) से बचाता है क्योंकि यह ownership नहीं रखता।
  8. 8. Lambda expression C++ में किस version से available है?

    • AC++98
    • BC++03
    • CC++11
    • DC++17
    Show Correct Answer
    Explanation Lambdas C++11 में introduce हुए। ये anonymous functions बनाने के लिए उपयोग होते हैं।
  9. 9. Modern C++ में auto keyword का उपयोग मुख्य रूप से किस लिए होता है?

    • AVariable type automatically deduce करने के लिए
    • BPointer बनाने के लिए
    • CConstant बनाने के लिए
    • DFunction return type बदलने के लिए
    Show Correct Answer
    Explanation auto compiler को type deduce करने देता है, जिससे code clean और maintainable बनता है।
  10. 10. constexpr functions का मुख्य लाभ क्या है?

    • ARuntime पर execute होते हैं
    • BCompile-time पर evaluate हो सकते हैं
    • Cकेवल void return करते हैं
    • DMemory usage बढ़ाते हैं
    Show Correct Answer
    Explanation constexpr compile-time computation allow करता है जिससे performance बेहतर होती है।
  11. 11. std::make_unique और new में क्या advantage है?

    • AFaster execution
    • BException safety प्रदान करता है
    • Cअधिक memory उपयोग करता है
    • DCopy create करता है
    Show Correct Answer
    Explanation std::make_unique exception-safe है क्योंकि allocation और constructor call एक साथ होते हैं।
  12. 12. Perfect forwarding का उपयोग मुख्य रूप से किस लिए होता है?

    • ATemplates में arguments forward करने के लिए
    • BPointers delete करने के लिए
    • CClasses inherit करने के लिए
    • DLoops optimize करने के लिए
    Show Correct Answer
    Explanation std::forward<T>() universal references के साथ perfect forwarding करता है।
  13. 13. Rule of Five किसको refer करता है?

    • A5 constructors बनाना
    • BCopy constructor, copy assignment, move constructor, move assignment, destructor implement करना
    • C5 inheritance rules
    • D5 STL containers
    Show Correct Answer
    Explanation Resource management के लिए Rule of Five follow करना चाहिए (C++11 से)।
  14. 14. Base class में virtual destructor क्यों जरूरी होता है?

    • AMemory leak से बचने के लिए
    • BPolymorphic deletion सही तरीके से करने के लिए
    • CSpeed बढ़ाने के लिए
    • DCode छोटा करने के लिए
    Show Correct Answer
    Explanation Derived object को base pointer से delete करने पर virtual destructor न होने से derived destructor call नहीं होता।
  15. 15. std::enable_if का उपयोग क्या है?

    • ACompile-time type checking के लिए
    • BRuntime error throw करने के लिए
    • CMemory allocate करने के लिए
    • DLoop break करने के लिए
    Show Correct Answer
    Explanation SFINAE के साथ templates को conditionally enable/disable करने के लिए।
  16. 16. Concepts C++ में किस version में officially introduce हुए?

    • AC++11
    • BC++14
    • CC++17
    • DC++20
    Show Correct Answer
    Explanation C++20 में concepts आए जो template constraints के लिए बेहतर और readable syntax देते हैं।
  17. 17. auto&& का मतलब universal reference में क्या होता है?

    • Aकेवल rvalue bind होता है
    • Blvalue और rvalue दोनों bind हो सकते हैं
    • CConstant reference
    • DPointer reference
    Show Correct Answer
    Explanation जब T auto या template parameter हो तो T&& universal reference बन जाता है।
  18. 18. std::forward का सामान्य syntax क्या है?

    • Astd::forward(arg)
    • Bstd::forward<T>(arg)
    • Cstd::move<T>(arg)
    • Dstd::cast<T>(arg)
    Show Correct Answer
    Explanation Perfect forwarding के लिए std::forward<T>() का उपयोग होता है।
  19. 19. std::variant किस header में define है?

    • A<memory>
    • B<variant>
    • C<optional>
    • D<utility>
    Show Correct Answer
    Explanation C++17 में union का type-safe alternative प्रदान करता है।
  20. 20. std::optional का उपयोग कब करते हैं?

    • Aजब value हो या न हो (nullable)
    • Bजब multiple values रखने हों
    • CException handling के लिए
    • DPointer इस्तेमाल करने के लिए
    Show Correct Answer
    Explanation std::optional<T> value या nullopt रख सकता है। यह raw pointer का बेहतर विकल्प है।
  21. 21. Thread-local storage के लिए keyword क्या है?

    • Astatic
    • Bthread_local
    • Cmutable
    • Dvolatile
    Show Correct Answer
    Explanation thread_local हर thread के लिए अलग variable copy बनाता है (C++11)।
  22. 22. std::mutex किस header में है?

    • A<thread>
    • B<mutex>
    • C<future>
    • D<atomic>
    Show Correct Answer
    Explanation Mutex locking के लिए <mutex> header इस्तेमाल होता है।
  23. 23. std::lock_guard का मुख्य लाभ क्या है?

    • AManual unlock करना पड़ता है
    • BRAII style में automatic unlock
    • CMultiple mutex lock करता है
    • DDeadlock create करता है
    Show Correct Answer
    Explanation Scope खत्म होने पर automatically unlock हो जाता है।
  24. 24. std::atomic का उपयोग किस लिए होता है?

    • AThread-safe variable operations के लिए
    • BFile handling के लिए
    • CString manipulation के लिए
    • DVector resize के लिए
    Show Correct Answer
    Explanation Lock-free thread-safe operations जैसे increment, load, store आदि।
  25. 25. Three-way comparison operator (spaceship) किस version में आया?

    • AC++11
    • BC++14
    • CC++17
    • DC++20
    Show Correct Answer
    Explanation <=> operator strong, weak और partial ordering प्रदान करता है।
  26. 26. std::span किस लिए उपयोगी है?

    • AContiguous memory का non-owning view देने के लिए
    • BDynamic array के लिए
    • CLinked list के लिए
    • DMap container के लिए
    Show Correct Answer
    Explanation C++20 में array/vector का non-owning view देता है।
  27. 27. CRTP का पूरा नाम और उपयोग क्या है?

    • ACuriously Recurring Template Pattern – static polymorphism
    • BCopy Runtime Template Pointer
    • CClass Runtime Template Pattern
    • DCompile Resource Type Pointer
    Show Correct Answer
    Explanation CRTP static dispatch के लिए इस्तेमाल होता है।
  28. 28. SFINAE का पूरा नाम क्या है?

    • ASubstitution Failure Is Not An Error
    • BSyntax Failure In Name Argument
    • CStatic Function In Namespace Error
    • DSimple Failure In New Expression
    Show Correct Answer
    Explanation Template substitution fail होने पर error नहीं होता, अगला candidate try किया जाता है।
  29. 29. std::decay_t<T> का उपयोग क्या है?

    • AReference और cv-qualifiers remove करने के लिए
    • BPointer बनाने के लिए
    • CConst बनाने के लिए
    • DArray को pointer में convert करने के लिए
    Show Correct Answer
    Explanation Type traits में raw type प्राप्त करने के लिए।
  30. 30. std::is_same_v<T, U> किस header में है?

    • A<type_traits>
    • B<memory>
    • C<concepts>
    • D<utility>
    Show Correct Answer
    Explanation Compile-time पर दो types की equality check करता है।
  31. 31. noexcept specifier का मतलब क्या है?

    • AFunction exception नहीं throw करेगा
    • BFunction हमेशा exception throw करेगा
    • CFunction virtual है
    • DFunction static है
    Show Correct Answer
    Explanation noexcept move operations में strong exception guarantee देता है।
  32. 32. final keyword class पर लगाने का मतलब?

    • AClass inherit नहीं हो सकती
    • BFunction override नहीं हो सकता
    • CVariable constant है
    • DPointer delete नहीं हो सकता
    Show Correct Answer
    Explanation final class को derive नहीं किया जा सकता (C++11)।
  33. 33. override keyword का लाभ क्या है?

    • AVirtual function सही override होने की confirmation देता है
    • BFunction delete करता है
    • CMemory allocate करता है
    • DLoop break करता है
    Show Correct Answer
    Explanation Compiler check करता है कि base में virtual function मौजूद है या नहीं।
  34. 34. Default member initializer किस version से उपलब्ध है?

    • AC++98
    • BC++11
    • CC++14
    • DC++17
    Show Correct Answer
    Explanation Class definition में ही member को default value दे सकते हैं।
  35. 35. Aggregate initialization किस तरह से होती है?

    • ABraces {} से
    • BParentheses () से
    • CEqual = से
    • DColon : से
    Show Correct Answer
    Explanation struct/class के public data members को {} से initialize कर सकते हैं।
  36. 36. std::string_view का मुख्य लाभ क्या है?

    • ANo copy, lightweight string reference
    • BMutable string
    • COwned string
    • Dहमेशा null-terminated
    Show Correct Answer
    Explanation C++17 में non-owning string view, substrings के लिए efficient।
  37. 37. std::byte का उपयोग किस लिए है?

    • ARaw memory byte represent करने के लिए
    • BCharacter store करने के लिए
    • CInteger value के लिए
    • DFloat value के लिए
    Show Correct Answer
    Explanation C++17 में type-safe byte manipulation के लिए।
  38. 38. if constexpr किस version में introduce हुआ?

    • AC++11
    • BC++14
    • CC++17
    • DC++20
    Show Correct Answer
    Explanation Compile-time branching allow करता है, dead code discard होता है।
  39. 39. std::filesystem किस version से standard library का हिस्सा है?

    • AC++11
    • BC++14
    • CC++17
    • DC++20
    Show Correct Answer
    Explanation File और directory operations के लिए <filesystem> header।
  40. 40. Coroutines C++ में किस version में officially आए?

    • AC++14
    • BC++17
    • CC++20
    • DC++23
    Show Correct Answer
    Explanation C++20 में async programming के लिए co_await, co_yield, co_return।
  41. 41. std::jthread का मुख्य लाभ क्या है?

    • ADestructor में automatically join होता है
    • BDetach होता है
    • CMutex lock करता है
    • DAtomic operation करता है
    Show Correct Answer
    Explanation C++20 में jthread RAII-style automatic join करता है।
  42. 42. std::format() function किस version में आया?

    • AC++17
    • BC++20
    • CC++23
    • DC++11
    Show Correct Answer
    Explanation Python-style string formatting C++20 में introduce हुआ।
  43. 43. requires clause का उपयोग क्या है?

    • AConcepts के साथ template constraints define करने के लिए
    • BException throw करने के लिए
    • CMemory allocate करने के लिए
    • DLoop control के लिए
    Show Correct Answer
    Explanation C++20 concepts में requires expression से constraints लागू करते हैं।
  44. 44. std::ranges::sort किस version में बेहतर support मिलता है?

    • AC++17
    • BC++20
    • CC++14
    • DC++11
    Show Correct Answer
    Explanation C++20 ranges library algorithms को composable बनाती है।
  45. 45. Deduction guides किसके लिए उपयोग होते हैं?

    • AClass template arguments deduce करने के लिए
    • BFunction return type deduce करने के लिए
    • CVariable type deduce करने के लिए
    • DPointer type deduce करने के लिए
    Show Correct Answer
    Explanation C++17 में user-defined deduction guides constructor arguments से type deduce करते हैं।
  46. 46. std::source_location किस लिए उपयोगी है?

    • ALogging में file, line, function information capture करने के लिए
    • BMemory address लेने के लिए
    • CTime measurement के लिए
    • DThread ID लेने के लिए
    Show Correct Answer
    Explanation C++20 में compile-time पर __FILE__, __LINE__ आदि capture करता है।
  47. 47. consteval keyword का मतलब क्या है?

    • AFunction केवल compile-time पर call हो सकती है
    • BFunction runtime पर call होगी
    • CFunction virtual है
    • DFunction deleted है
    Show Correct Answer
    Explanation C++20 में immediate function, compile-time guarantee देता है।
  48. 48. std::bit_cast<T>() का उपयोग क्या है?

    • AType punning को type-safe तरीके से करना
    • BPointer cast करना
    • CDynamic cast करना
    • DStatic cast करना
    Show Correct Answer
    Explanation C++20 में different types के बीच bit-level reinterpretation।
  49. 49. std::midpoint और std::lerp किस header में हैं?

    • A<numeric>
    • B<cmath>
    • C<algorithm>
    • D<ranges>
    Show Correct Answer
    Explanation C++20 में numeric functions midpoint और linear interpolation के लिए।
  50. 50. std::is_constant_evaluated() का उपयोग क्या है?

    • ACompile-time vs runtime call detect करने के लिए
    • BException check करने के लिए
    • CPointer check करने के लिए
    • DType check करने के लिए
    Show Correct Answer
    Explanation constexpr functions में बताता है कि call compile-time से है या runtime से।

Ready to check how well you know this topic?

Start Free Practice Test
View more Hindi Quiz MCQ papers