Free tutorials & notes in Hindi & English · Clean code examples 🧰 मुफ़्त PDF और फ़ोटो टूल्स →
🟢 Foundation  ·  Lesson 01

Cpp Test 2

C++ Test 2 – Functions, Pointers and OOP (50 Marks)

Total Marks: 50   |   Total Questions: 50   |   Time: 50 minutes   |   Marking: +1 for correct, 0 for wrong/unanswered.
  • One question will appear on the screen at a time.
  • Use Next and Previous buttons to move between questions.
  • Use the right-side question palette to jump to any question.
  • Use Mark for Review for questions you want to revisit.
  • The quiz auto-submits when time is over.
Test 2 50 Marks
50:00
Question 1 of 50

Question Palette

Purple = Answered
Yellow = Review
White = Not Answered

Answer key with explanations

Attempt the test and submit it first, then use this key to revise. Each answer has a short explanation so you understand why it is correct.

Show all 50 answers
  1. A class is

    Answer: A. Blueprint for objects – Class defines data and functions for objects.

  2. An object is

    Answer: A. Instance of a class – Object is created from a class.

  3. Which access specifier hides members from outside class?

    Answer: B. private – private members cannot be accessed directly outside class.

  4. Default access in a C++ class is

    Answer: B. private – Class members are private by default.

  5. Default access in a C++ struct is

    Answer: C. public – Struct members are public by default.

  6. Constructor name is same as

    Answer: B. Class name – Constructor has same name as class.

  7. Constructor return type is

    Answer: C. No return type – Constructor has no return type.

  8. Destructor name begins with

    Answer: B. ~ – Destructor name is ~ClassName.

  9. Which pointer refers to current object?

    Answer: B. this – this points to current object.

  10. Static data member belongs to

    Answer: A. Class – Static member is shared at class level.

  11. Friend function can access

    Answer: B. Private members if declared friend – friend function can access private/protected members.

  12. Inheritance supports

    Answer: A. Code reuse – Inheritance reuses and extends base class features.

  13. The class inherited from is called

    Answer: B. Base class – Base class is parent class.

  14. The inheriting class is called

    Answer: A. Derived class – Derived class inherits from base class.

  15. Which inheritance mode keeps public members public?

    Answer: C. public – Public inheritance keeps public members public.

  16. Polymorphism means

    Answer: A. Many forms – Polymorphism means one interface with many forms.

  17. Run-time polymorphism is achieved using

    Answer: A. Virtual functions – virtual functions support dynamic binding.

  18. Pure virtual function syntax includes

    Answer: A. = 0 – Pure virtual function ends with = 0.

  19. A class with pure virtual function is

    Answer: A. Abstract class – It becomes an abstract class.

  20. Operator overloading is used for

    Answer: A. User-defined meaning of operators – Operator overloading defines operator behavior for classes.

  21. Which operator cannot be overloaded?

    Answer: C. :: – Scope resolution operator :: cannot be overloaded.

  22. Templates enable

    Answer: A. Generic programming – Templates work with different data types generically.

  23. Which keyword starts a function template?

    Answer: A. template – template starts template declaration.

  24. Exception handling uses

    Answer: A. try, throw, catch – try-throw-catch handles exceptions.

  25. Which keyword throws an exception?

    Answer: B. throw – throw raises an exception.

  26. Which keyword handles an exception?

    Answer: A. catch – catch handles thrown exception.

  27. STL stands for

    Answer: A. Standard Template Library – STL means Standard Template Library.

  28. Which STL container is dynamic array?

    Answer: A. vector – vector is dynamic array.

  29. Which vector function adds element at end?

    Answer: A. push_back – push_back appends element.

  30. Which STL container stores unique sorted values?

    Answer: A. set – set stores unique sorted keys.

  31. Which STL container stores key-value pairs?

    Answer: A. map – map stores key-value pairs.

  32. Which data structure follows LIFO?

    Answer: A. Stack – Stack follows Last In First Out.

  33. Which data structure follows FIFO?

    Answer: B. Queue – Queue follows First In First Out.

  34. Which function gets top element of stack?

    Answer: C. top() – stack uses top().

  35. Which algorithm sorts a vector?

    Answer: A. sort() – sort(begin,end) sorts a range.

  36. Which header contains sort()?

    Answer: A. <algorithm> – sort is declared in <algorithm>.

  37. Which iterator points to first element?

    Answer: A. begin() – begin() returns iterator to first element.

  38. Which iterator points after the last element?

    Answer: B. end() – end() points one past last element.

  39. Range-based for loop syntax uses

    Answer: A. for(auto x : container) – C++ range-for uses colon.

  40. auto keyword is used to

    Answer: A. Let compiler infer type – auto deduces type from initializer.

  41. lambda expression is

    Answer: A. Unnamed function – Lambda is an anonymous function object.

  42. Smart pointers are available in

    Answer: A. <memory> – <memory> provides smart pointers.

  43. unique_ptr means

    Answer: A. Single ownership – unique_ptr has exclusive ownership.

  44. shared_ptr means

    Answer: A. Shared ownership – shared_ptr shares ownership through reference counting.

  45. RAII is mainly about

    Answer: A. Resource management through object lifetime – RAII ties resource release to object destruction.

  46. binary_search requires range to be

    Answer: A. Sorted – binary_search expects sorted range.

  47. Which function reverses a range?

    Answer: A. reverse() – reverse(begin,end) reverses order.

  48. Which program design is best for a student management project?

    Answer: A. Use classes and file handling – Classes and files make project organized.

  49. Encapsulation means

    Answer: A. Wrapping data and methods together with controlled access – Encapsulation protects data inside class.

  50. Abstraction means

    Answer: A. Showing essential details and hiding internal complexity – Abstraction hides implementation details.

← Back to C++ Tutorial
🔗

Share this topic with a friend

यह topic किसी दोस्त को भेजें

Found it useful? Send it to a classmate learning the same thing.

अच्छा लगा? जो दोस्त यही सीख रहा है, उसे भेज दीजिए।

यह lesson कैसा लगा?

आपकी राय से हम content और बेहतर बनाते हैं।

अपना review और सुझाव लिखें (वैकल्पिक)

Review approve होने के बाद आपका नाम और शहर इसके साथ public दिख सकते हैं। Email या phone न लिखें।

▶ CodingEasily on YouTube

Video से सीखें – आसान Hindi में

चुनी हुई video: RDBMS भाग 3 – Class XI Commerce IT

▶ Channel subscribe करें