Cpp Programming 6

COEP
Lets Crack Online Exam

IT Interview Exam Questions: Cpp Programming 1 (IT Interview Exam Question, IT Campus Placement)

Subject: Cpp Programming 6

Part 6: List for questions and answers of C ++ Language

 

Q1. A constructor that accepts __________ parameters is called the default constructor

a) one

b) two

c) no

d) three

 

Q2. What happens when a class with parameterized constructors and having no default constructor is used in a program and we create an object that needs a zero-argument constructor?

a) Compile-time error

b) Preprocessing error

c) Runtime error

d) Runtime exception

 

Q3. Destructor has the same name as the constructor and it is preceded by ______

a) !

b) ?

c) ~

d) $

 

Q4. For automatic objects, constructors and destructors are called each time the objects

a) enter and leave scope

b) inherit parent class

c) are constructed

d) are destroyed

 

Q5. Which constructor function is designed to copy objects of the same class type?

a) Create constructor

b) Object constructor

c) Dynamic constructor

d) Copy constructor

 

Q6. Which of the following statement is correct?

a) Constructor has the same name as that of the class

b) Destructor has the same name as that of the class with a tilde symbol at the beginning

c) Both A and B

d) Destructor has the same name as the first member function of the class 

 

Q7. Which of the following statement is incorrect?

a) Constructor is a member function of the class

b) The compiler always provides a zero argument constructor

c) It is necessary that a constructor in a class should always be public

d) Both B and C

 

Q8. When are the Global objects destroyed?

a) When the control comes out of the block in which they are being used

b) When the program terminates

c) When the control comes out of the function in which they are being used

d) As soon as local objects die

 

Q9. Copy constructor must receive its arguments by __________

a) either pass-by-value or pass-by-reference

b) only pass-by-value

c) only pass-by-reference

d) only pass by address

 

Q10. A function with the same name as the class, but preceded with a tilde character (~) is called __________ of that class

a) constructor

b) destructor

c) function

d) object

 

Q11. A union that has no constructor can be initialized with another union of __________ type

a) different

b) same

c) virtual

d) class

 

Q12. Which of the following gets called when an object goes out of scope?

a) constructor

b) destructor

c) main

d) virtual function 

 

Q13. Which of the following statement is correct?

a) Destructor destroys only integer data members of the object

b) Destructor destroys only float data members of the object

c) Destructor destroys only pointer data members of the object

d) Destructor destroys the complete object

 

Q14. __________ used to make a copy of one class object from another class object of the same class type

a) constructor

b) copy constructor

c) destructor

d) default constructor

 

Q15. Constructors __________ to allow different approaches of object construction

a) cannot overloaded

b) can be overloaded

c) can be called

d) can be nested

 

Q16. Which of the following statement is correct?

a) A destructor has the same name as the class in which it is present

b) A destructor has a different name than the class in which it is present

c) A destructor always returns an integer

d) A destructor can be overloaded

 

Q17. Which of the following cannot be declared as virtual?

a) Constructor

b) Destructor

c) Data Members

d) Both A and C

 

Q18. If the copy constructor receives its arguments by value, the copy constructor would

a) call one-argument constructor of the class

b) work without any problem

c) call itself recursively

d) call zero-argument constructor 

 

Q19. Which of the following are NOT provided by the compiler by default?

a) Zero-argument Constructor

b) Destructor

c) Copy Constructor

d) Copy Destructor

 

Q20. It is a __________ error to pass arguments to a destructor

a) logical

b) virtual

c) syntax

d) linker 

 

Part 6: List for questions and answers of C ++ Language

 

Q1. Answer: c

 

Q2. Answer: a

 

Q3. Answer: c

 

Q4. Answer: a

 

Q5. Answer: d

 

Q6. Answer: c

 

Q7. Answer: d

 

Q8. Answer: b

 

Q9. Answer: c

 

Q10. Answer: b

 

Q11. Answer: b

 

Q12. Answer: b

 

Q13. Answer: d

 

Q14. Answer: b

 

Q15. Answer: b

 

Q16. Answer: a

 

Q17. Answer: d

 

Q18. Answer: c

 

Q19. Answer: d

 

Q20. Answer: c