Cpp Programming 4

COEP
Lets Crack Online Exam

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

Subject: Cpp Programming 4

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

 

Q1. Which of the following is false?

a) Variable has scope and visibility

b) Variables having scope may not be visible

c) Variables having visibility may not have scope

d) None of these

 

Q2. For a method to be an interface between the outside world and a class,it has to be declared ?

a) private

b) protected

c) public

d) external

 

Q3. In C++, a function contained within the class is called ?

a) member function

b) a class function

c) a method

d) none of above

 

Q4. classes are useful because they

a) are removed from memory when not in use

b) permit data to be hidden from other classes

c) bring together all aspects of an entity in one place

d) can closely model objects in the real world

 

Q5. The public files in a class library usually contain ?

a) Constant definitions

b) member function definitions

c) class declarations

d) variable definition

 

Q6. A class cannot be ?

a) Virtual

b) Generic

c) Inline

d) Friend 

 

Q7. Objects of the same class share the values of …… while they maintain separate values for ……..

a) Static variables, non static variables

b) Non static variables, static variables

c) Global variables, static variables

d) Static variables, register variables

 

Q8. Which of the following keywords cannot appear inside a class definition ?

a) friend

b) static

c) template

d) virtual

 

Q9. Shallow copy is

a) Member wise copying of objects

b) A substitute for the operator

c) Same kind like deep copy

d) Used in constructor

 

Q10. Which member function of class cannot modify its objects attributes ?

a) friend functions

b) Private member functions

c) Constant member functions

d) Static member functions

 

Q11. What happens when we try to compile the class definition in following code snippet? class Birds {}; class Peacock : protected Birds {};

a) It will not compile because class body of Birds is not defined

b) It will not compile because class body of Peacock is not defined

c) It will not compile because a class cannot be protectedly inherited from other class

d) It will compile succesfully

 

Q12. Which of the following statements is incorrect?

a) Friend keyword can be used in the class to allow access to another class

b) Friend keyword can be used for a function in the public section of a class

c) Friend keyword can be used for a function in the private section of a class

d) Friend keyword can be used on main() 

 

Q13. Which of the following statement is correct regarding destructor of base class?

a) Destructor of base class should always be static

b) Destructor of base class should always be virtual

c) Destructor of base class should not be virtual

d) Destructor of base class should always be private

 

Q14. Which of the following two entities (reading from Left to Right) can be connected by the dot operator?

a) A class member and a class object

b) A class object and a class

c) A class and a member of that class

d) A class object and a member of that class

 

Q15. How can we make a class abstract?

a) By making all member functions constant

b) By making at least one member function as pure virtual function

c) By declaring it abstract using the static keyword

d) By declaring it abstract using the virtual keyword

 

Q16. Which of the following statements is correct when a class is inherited publicly?

a) Public members of the base class become protected members of derived class

b) Public members of the base class become private members of derived class

c) Private members of the base class become protected members of derived class

d) Public members of the base class become public members of derived class

 

Q17. Which of the following statements is correct about the constructors and destructors?

a) Destructors can take arguments but constructors cannot

b) Constructors can take arguments but destructors cannot

c) Destructors can be overloaded but constructors cannot be overloaded

d) Constructors and destructors can both return a value

 

Q18. Which of the following access specifies is used in a class definition by default?

a) Protected

b) Public

c) Private

d) Friend 

 

Q19. Which of the following statement is correct with respect to the use of friend keyword inside a class?

a) A private data member can be declared as a friend

b) A class may be declared as a friend

c) An object may be declared as a friend

d) We can use friend keyword as a class name

 

Q20. Which of the following keywords is used to control access to a class member?

a) Default

b) Break

c) Protected

d) Asm 

 

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

 

Q1. Answer: c

 

Q2. Answer: c

 

Q3. Answer: a

 

Q4. Answer: b

 

Q5. Answer: c

 

Q6. Answer: c

 

Q7. Answer: a

 

Q8. Answer: c

 

Q9. Answer: a

 

Q10. Answer: c

 

Q11. Answer: d

 

Q12. Answer: d

 

Q13. Answer: b

 

Q14. Answer: d

 

Q15. Answer: b

 

Q16. Answer: d

 

Q17. Answer: b

 

Q18. Answer: c

 

Q19. Answer: b

 

Q20. Answer: c