Blog - C ++ Language Quiz 2

C ++ Language Quiz 2

C ++ Language Quiz 2

C++language

1.How are C++ exceptions different from C error handling using return codes?

      C++ अपवाद रिटर्न कोड का उपयोग करके C त्रुटि प्रबंधन से किस प्रकार भिन्न हैं?

a) C++ exceptions are used for handling runtime errors, while return codes are used for compile-time errors.

b) C++ exceptions provide a more structured way to handle errors and propagate them up the call stack, while return codes require explicit error checking after each function call.

c) C++ exceptions are only used for handling hardware errors, while return codes are used for software errors.

d) C++ exceptions and return codes are functionally equivalent.

 

 

2.What is the purpose of the "const" keyword when applied to a member function in C++?

C++ में किसी सदस्य फ़ंक्शन पर लागू होने पर "कॉन्स्ट" कीवर्ड का उद्देश्य क्या है?

a) To make the member function static

b) To indicate that the member function cannot modify the object's data members

c) To make the member function a friend of the class

d) To declare a constant variable

 

3.What is the purpose of the "delete" operator in C++?

    C++ में "उपयोग" निर्देश का उद्देश्य क्या है?

a) To remove a class definition

b) To deallocate memory for a dynamically allocated object

c) To delete a file

d) To remove a function definition

 

4.What is a copy constructor in C++, and when is it automatically generated by the compiler?

   C++ में कॉपी कंस्ट्रक्टर क्या है, और यह कंपाइलर द्वारा स्वचालित रूप से कब उत्पन्न होता है?

a) A copy constructor is used to create a deep copy of an object. It is always automatically generated by the compiler.

b) A copy constructor is used to create a shallow copy of an object. It is always automatically generated by the compiler.

c) A copy constructor is used to create a deep copy of an object. It is generated by the compiler only if the class does not define its own copy constructor.

d) A copy constructor is used to create a shallow copy of an object. It is generated by the compiler only if the class defines its own copy constructor.

 

5.In C++, what is the purpose of the "const" keyword when applied to a pointer?

C++ में, पॉइंटर पर लागू होने पर "const" कीवर्ड का उद्देश्य क्या होता है?

a) To indicate that the pointer cannot be dereferenced

b) To make the pointer a friend of the class

c) To declare a constant variable

d) To indicate that the pointed-to object cannot be modified through the pointer

 

6.What is a virtual destructor in C++, and why is it useful in inheritance hierarchies?

C++ में वर्चुअल डिस्ट्रक्टर क्या है, और यह इनहेरिटेंस पदानुक्रम में उपयोगी क्यों है?

a) A virtual destructor is a destructor that is declared as virtual in the base class. It ensures that the correct destructor is called when deleting an object through a base class pointer in a derived class.

b) A virtual destructor is a destructor that is automatically generated by the compiler and cannot be overridden.

c) A virtual destructor is a destructor that can only be called once.

d) A virtual destructor is a destructor that is used to deallocate memory.

 

7.What is a pure virtual function in C++, and how is it declared?

C++ में शुद्ध वर्चुअल फ़ंक्शन क्या है, और इसे कैसे घोषित किया जाता है?

a) A pure virtual function is a function with no body that is declared with the "virtual" keyword.

b) A pure virtual function is a function with an empty body.

c) A pure virtual function is a function that cannot be called.

d) A pure virtual function is a function that can only be called once.

 

8.What is the purpose of the "typeid" operator in C++?

C++ में "टाइपआईडी" ऑपरेटर का उद्देश्य क्या है?

a) To calculate the type of an object at runtime

b) To check if a pointer is null

c) To convert one data type to another

d) To create a new object

 

9.What is function overloading in C++, and how is it achieved?

C++ में फ़ंक्शन ओवरलोडिंग क्या है, और इसे कैसे प्राप्त किया जाता है?

a) Function overloading is the ability to define multiple functions with the same name but different parameter lists. It is achieved by changing the function name.

b) Function overloading is the ability to define multiple functions with the same name but different parameter lists. It is achieved by changing the return type.

c) Function overloading is not allowed in C++. d) Function overloading is the ability to define multiple functions with the same name and the same parameter list.

 

10.What is the purpose of the "const_cast" operator in C++?

C++ में "const_cast" ऑपरेटर का उद्देश्य क्या है?

a) To cast away the constantness of an object or a pointer to an object

b) To cast a variable to a constant c) To cast a constant variable to a non-constant variable

d) To cast a constant object to a different type

 

11.In C++, what is an inline function, and why is it used?

C++ में इनलाइन फ़ंक्शन क्या है और इसका उपयोग क्यों किया जाता है?

a) An inline function is a function that cannot be called from other functions. It is used for internal calculations only.

b) An inline function is a function that is defined within a class. It is used to access private members of the class.

c) An inline function is a function that is expanded by the compiler at the point of the call. It is used to improve performance by reducing function call overhead.

d) An inline function is a function that is declared in a header file. It is used to declare global functions.

 

12.What is the purpose of the "std" namespace in C++?

C++ में "std" नेमस्पेस का उद्देश्य क्या है?

a) To specify the standard input and output streams

b) To specify the standard error stream

c) To group C++ standard library elements into a named scope

d) To declare standard variables

 

13.What is the purpose of the "using" directive in C++?

C++ में "उपयोग" निर्देश का उद्देश्य क्या है?

a) To define a function

b) To include a header file

c) To import a namespace into the current scope

d) To create a class

 

14.What is a lambda expression in C++, and why is it useful?

C++ में लैम्ब्डा एक्सप्रेशन क्या है और यह उपयोगी क्यों है?

a) A lambda expression is a predefined function provided by the C++ standard library. It is useful for mathematical calculations.

b) A lambda expression is a shorthand way to define anonymous functions. It is useful for writing small, inline functions.

c) A lambda expression is a user-defined data type. It is useful for creating custom objects.

d) A lambda expression is a keyword used for memory allocation. It is useful for allocating memory on the heap.

 

 

15.What is the purpose of the "const" qualifier when used with a member function in C++?

C++ में सदस्य फ़ंक्शन के साथ उपयोग किए जाने पर "कॉन्स्ट" क्वालिफायर का उद्देश्य क्या है?

a) To indicate that the member function cannot be called

b) To indicate that the member function is a constructor

c) To indicate that the member function does not modify the object's data members

d) To indicate that the member function is a destructor

 

 

16.What is operator overloading in C++, and why is it used?

C++ में ऑपरेटर ओवरलोडिंग क्या है और इसका उपयोग क्यों किया जाता है?

a) Operator overloading is the ability to define multiple operators with the same functionality. It is used to create confusion in code.

b) Operator overloading is the ability to define custom behaviors for operators when applied to user-defined types. It is used to make code more intuitive and expressive.

c) Operator overloading is not allowed in C++.

d) Operator overloading is the ability to define new operators.

 

 

17.What is the purpose of the "const" keyword when used with a member variable in a class in C++?

C++ में किसी वर्ग में सदस्य चर के साथ उपयोग किए जाने पर "कॉन्स्ट" कीवर्ड का उद्देश्य क्या है?

a) To indicate that the member variable is a constant and cannot be modified

b) To indicate that the member variable is a constructor

c) To indicate that the member variable is a destructor

d) To indicate that the member variable is a friend of the class

 

18.What is the purpose of the "reinterpret_cast" operator in C++?

C++ में "reinterpret_cast" ऑपरेटर का उद्देश्य क्या है?

a) To convert one data type to another in a type-safe manner

b) To perform arithmetic operations

c) To cast one pointer type to another, even if they are unrelated

d) To create a new object

 

 

19.In C++, what is multiple inheritance, and how is it implemented?

C++ में, एकाधिक वंशानुक्रम क्या है, और इसे कैसे कार्यान्वित किया जाता है?

a) Multiple inheritance is the ability of a class to inherit from multiple base classes. It is implemented by specifying multiple base classes separated by commas in the class declaration.

b) Multiple inheritance is not allowed in C++.

c) Multiple inheritance is the ability of a class to inherit from multiple base classes. It is implemented by creating a new class that inherits from the base classes.

d) Multiple inheritance is the ability of a class to have multiple constructors.

 

20.What is the difference between shallow copy and deep copy in C++ when copying objects?

ऑब्जेक्ट कॉपी करते समय C++ में शैलो कॉपी और डीप कॉपी के बीच क्या अंतर है?

a) Shallow copy creates a new object with the same data members as the original object. Deep copy creates a new object with its own copy of dynamically allocated data.

b) Shallow copy creates a new object with its own copy of dynamically allocated data. Deep copy creates a new object with the same data members as the original object.

c) Shallow copy and deep copy are the same.

d) Shallow copy and deep copy are not allowed in C++.

 

21.What is a smart pointer in C++, and why is it used?

C++ में स्मार्ट पॉइंटर क्या है और इसका उपयोग क्यों किया जाता है?

a) A smart pointer is a data type that stores integers. It is used for mathematical calculations.

b) A smart pointer is a type of pointer that manages the memory of dynamically allocated objects. It is used to prevent memory leaks and simplify memory management.

c) A smart pointer is a type of pointer that cannot be dereferenced. It is used to improve code safety.

d) A smart pointer is a type of pointer that can only point to objects of a specific class. It is used to restrict object access.

 

22.What is a reference variable in C++, and how is it different from a regular variable?

C++ में रेफरेंस वेरिएबल क्या है, और यह नियमित वेरिएबल से कैसे भिन्न है?

a) A reference variable is a variable that cannot be modified after initialization. It is the same as a regular variable.

b) A reference variable is an alias for an existing variable. Changes made to the reference variable also affect the original variable.

c) A reference variable is a variable that can be used without declaration. It is the same as a regular variable.

d) A reference variable is a variable with a longer lifetime than a regular variable.

 

23.What is the purpose of the "const" keyword when used with a pointer in C++?

C++ में पॉइंटर के साथ उपयोग किए जाने पर "कॉन्स्ट" कीवर्ड का उद्देश्य क्या है?

a) To declare a constant variable

b) To indicate that the pointer is null

c) To indicate that the pointed-to object cannot be modified through the pointer

d) To declare a function as a constant function

 

24.What is the difference between "new" and "malloc()" in C++ for dynamic memory allocation?

गतिशील मेमोरी आवंटन के लिए C++ में "नए" और "मॉलोक ()" के बीच क्या अंतर है?

a) "new" is used to allocate memory for objects with constructors, while "malloc()" is used for basic memory allocation.

b) "new" is used for array allocation, while "malloc()" is used for single object allocation.

c) "new" and "malloc()" are functionally equivalent.

d) "new" is used for single object allocation, while "malloc()" is used for array allocation.

 

 

25.What is the purpose of the "delete" operator in C++ for objects created with "new"?

"नए" के साथ बनाई गई वस्तुओं के लिए C++ में "डिलीट" ऑपरेटर का उद्देश्य क्या है?

a) To deallocate memory for a single object

b) To destroy an object

c) To remove a class definition

d) To remove a function definition

 


60 8 months ago