C++ Programming MCQ (Multiple Choice Questions) - SchoolingAxis

C++ Programming MCQ (Multiple Choice Questions)

 Que- Where does the object is created? 

a. class 

b. constructor 

c. destructor 

d. attributes 


Answer- class 


Que- How to access the object in the class? 

a. scope resolution operator 

b. ternary operator 

c. direct member access operator 

d. resolution operator 


Answer- direct member access operator 


Que- Which of these following members are not accessed by using direct member access operator? 

a. public 

b. private 

c. protected 

d. both private & protected 


Answer- both private & protected 


Que- Pick out the other definition of objects. 

a. member of the class 

b. associate of the class 

c. attribute of the class 

d. instance of the class 


Answer- instance of the class 


Que- How many objects can present in a single class? 

a. 1 

b. 2 

c. 3 

d. as many as possible 


Answer- as many as possible 


Que- Pick the other name of operator function. 

a. function overloading 

b. operator overloading 

c. member overloading 

d. object overloading 


Answer- operator overloading 


Que- Which of the following operators can't be overloaded? 

a. :: 

b. + 

c. – 

d. [] 


Answer- :: 


Que- How to declare operator function? 

a. operator sign 

b. operator 

c. name of the operator 

d. name of the class 


Answer- operator sign 


Que- What is operator overloading in C++? 

a. Overriding the operator meaning by the user defined meaning for user defined data type 

b. Redefining the way operator works for user defined types 

c. Ability to provide the operators with some special meaning for user defined data type 

d. All of the mentioned 


Answer- All of the mentioned 


Que- What is the syntax of overloading operator + for class A? 

a. A operator+(argument_list){} 

b. A operator[+](argument_list){} 

c. int +(argument_list){} 

d. int [+](argument_list){} 


Answer- A operator+(argument_list){} 


Que- How many approaches are used for operator overloading? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 3 


Que- Which of the following operator cannot be overloaded? 

a. + 

b. ?: 

c. – 

d. % 


Answer- ?: 


Que- Which of the following operator can be overloaded? 

a. ?: 

b. :: 

c. . 

d. == 


Answer- == 


Que- In case of non-static member functions how many maximum object arguments a unary operator overloaded function can take? 

a. 1 

b. 2 

c. 3 

d. 0 


Answer- 0 


Que- In case of non-static member functions how many maximum object arguments a binary operator overloaded function can take? 

a. 1 

b. 2 

c. 3 

d. 0 


Answer- 1 


Que- In the case of friend operator overloaded functions how many maximum object arguments a unary operator overloaded function can take? 

a. 1 

b. 2 

c. 3 

d. 0 


Answer- 1 


Que- In the case of friend operator overloaded functions how many maximum object arguments a binary operator overloaded function can take? 

a. 1 

b. 2 

c. 3 

d. 0 


Answer- 2 


Que- What is a binary operator? 

a. Operator that performs its action on a single operand 

b. Operator that performs its action on two operand 

c. Operator that performs its action on three operand 

d. Operator that performs its action on any number of operands 


Answer- Operator that performs its action on two operand 


Que- Which is the correct example of a binary operator? 

a. ++ 

b. — 

c. Dereferencing operator(*) 

d. + 


Answer- + 


Que- Which is the correct example of a unary operator? 

a. & 

b. == 

c. — 

d. / 


Answer- — 


Que- Which is the correct statement about operator overloading? 

a. Only arithmetic operators can be overloaded 

b. Only non-arithmetic operators can be overloaded 

c. Precedence of operators are changed after overlaoding 

d. Associativity and precedence of operators does not change 


Answer- Associativity and precedence of operators does not change 


Que- Pick the incorrect statements out of the following. 

a. Operator overloading does not disturbs the precedence of operators 

b. Arity of operators can be changed using operator overloading 

c. No new operators can be created 

d. All of the mentioned 


Answer- Arity of operators can be changed using operator overloading 


Que- Which header file is used to declare the complex number? 

a. complexnum 

b. complex 

c. complex number 

d. complexarg 


Answer- complex 


Que- How to declare the complex number? 

a. (3, 4) 

b. complex(3, 4) 

c. (3, 4i) 

d. (3, 4g) 


Answer- complex(3, 4) 


Que- How many real types are there in complex numbers? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 3 


Que- Which of the following is not a function of complex values? 

a. real 

b. imag 

c. norm 

d. cartesian 


Answer- cartesian 


Que- What is the return type of the conversion operator? 

a. void 

b. int 

c. float 

d. no return type 


Answer- no return type 


Que- Why we use the "dynamic_cast" type conversion? 

a. result of the type conversion is a valid 

b. to be used in low memory 

c. result of the type conversion is an invalid 

d. it is used for storage 


Answer- result of the type conversion is a valid 


Que- How many parameters does a conversion operator may take? 

a. 0 

b. 1 

c. 2 

d. as many as possible 


Answer- 0 


Que- How are types therein user-defined conversion? 

a. 1 

b. 2 

c. 3 

d. 4 


Answer- 2 


Que- Pick out the correct syntax of operator conversion. 

a. operator float()const 

b. operator float() 

c. operator const 

d. operator const() 


Answer- operator float()const 


Que- Which rule will not affect the friend function? 

a. private and protected members of a class cannot be accessed from outside 

b. private and protected member can be accessed anywhere 

c. protected member can be accessed anywhere 

d. private member can be accessed anywhere 


Answer- private and protected members of a class cannot be accessed from outside 


Que- Which keyword is used to declare the friend function? 

a. firend 

b. friend 

c. classfriend 

d. myfriend 


Answer- friend 


Que- What is the syntax of friend function? 

a. friend class1 Class2; 

b. friend class; 

c. friend class 

d. friend class() 


Answer- friend class1 Class2; 


Que- Pick out the correct statement. 

a. A friend function may be a member of another class 

b. A friend function may not be a member of another class 

c. A friend function may or may not be a member of another class 

d. None of the mentioned 


Answer- A friend function may or may not be a member of another class 


Que- Where does keyword 'friend' should be placed? 

a. function declaration 

b. function definition 

c. main function 

d. block function 


Answer- function declaration 


Que- What is a friend function in C++? 

a. A function which can access all the private, protected and public members of a class 

b. A function which is not allowed to access any member of any class 

c. A function which is allowed to access public and protected members of a class 

d. A function which is allowed to access only public members of a class 


Answer- A function which can access all the private, protected and public members of a class 


Que- Pick the correct statement. 

a. Friend functions are in the scope of a class 

b. Friend functions can be called using class objects 

c. Friend functions can be invoked as a normal function 

d. Friend functions can access only protected members not the private members 


Answer- Friend functions can be invoked as a normal function 


Que- Which of the following is correct about friend functions? 

a. Friend functions use the dot operator to access members of a class using class objects 

b. Friend functions can be private or public 

c. Friend cannot access the members of the class directly 

d. All of the mentioned 


Answer- All of the mentioned 


Que- Which keyword is used to represent a friend function? 

a. friend 

b. Friend 

c. friend_func 

d. Friend_func 


Answer- friend

Previous Post Next Post