Oops & C++ exercises

 Oops & C++ exercises




 Oops & C++ exercises













1)      Operator << is overloaded in the standard library class 
  A: ostream                      
  B: istream
 C: fstream                            
 D: iostream
        
2)      In C++ friend is a 
  A: Data type                                     
 B: Function
 C:Keyword                       
 D: Class name
  
3)      Which of the following access specifiers are available in c++?
A: Private                                
B: Protected
C: Public                                  
D: All the above 
 
4)      What is the static variable in the class?
  A: The static variables are used to maintain values common on the entire class.
   B: It is like the private member class.
   C: It can declare outside the class.
   D: It can declare global to maintain constant value in program.
 
5)      What are the two major components of the object?
   A: Data members               
   B: member function
  C: Both i and ii             
  D: None of the above

6)      Which of the following operators can be overloaded?
   A:  .(dot) and  :: (scope resolution)           
   B:  ?:
   C: new and delete                                     
  D: None of the above

7)      How data hiding is possible within a class?
  A: By private declaration      
  B: By public declaration
  C: By protected declaration                       
  D: By friend declaration


8)      What is an anonymous class?
   A: Whenever a class is defined without any name.
   B: When structure is defined in a class
  C:When object is defined in a class.
   D: When template are defined in a class.
      
9)         What is the difference between structure and class?
A: The data members of strucure are by default public and the data members of  the class by default private
    B: The data members of structure are private and data members of class are public.
    C: The data members of both structure and class are by default public.
    D: The data members of both structure and class are by default private.
   
10)  What is encapsulation?
    A: Binding of data and function together into single entity.
     B: Binding data and class in single entity.
     C: Binding data and structure in single entity.
     D: Binding function and class in single entity.

11)  How many access specifiers are there in C++?
   A: 2                        
   B: 1
   C: 4                           
  D: 3

12)  What is an object?
  A: It is the data member of the class          
 B: It is data member of structure
 C: It is instant of class                   
 D: It is the function of the class

13)  When does this pointer get created?
    A: The this pointer get created when a member function (non static) of class is called.    
    B: When constructor is called
    C: When destructor is called
    D: When constructor and destructor both are called.
  
14)  In function overloading the functions have
A: different number of arguments                  
B: different types of argument
C: different order of arguments                      
D: All of the above


       
15)  Which of the following operator cannot be overloaded?
A: new                                              
B: delete
C:  ?:                              
D: All of the above.
    
16)  Which of the following statement is not correct?
    A: A friend function can access public as well as private data members of the class.
    B: A friend function is not called using . (dot) and -> (arrow) operators.
    C: this pointer is available in friend function.
    D: All of the above.

17)  Which of the following statement is correct?
    A: Precedence cannot be changed through overloading
    B: Overloading is not allowed for user-defined types
   C: new and delete operator cannot be overloaded
    D: All of the above

18)  When an operator works on various types of operands is called 
A: Operator overloading       
B: Operator classification
C: Operator initialization            
D: All of the above
 
19)  _________ provides automatic initialization of objects.
    A: destructor
    B: member function
    C: constructor    
    D: automatic initialization of objects is not allowed in C++

20)  Select the correct alternative for the following:
    I] Overloaded functions can return default values.
    II] Overloaded functions can also be written with the same prototype.
A: true, false                                         
B: false, false    
C: false, true                                        
D: true, true
 
21)  Select the correct alternative for the following:
    I]    Function can be overloaded any number of times.
    II]   Constants are always passed by value to a function.
    A: true, false                          
B: false, false
C: false, true   ....            

















 Oops & C++ exercises

0 commentaires: