Professional Documents
Culture Documents
Tosh Ibs Ir Te Am: Object Oriented Programming Using C++
Tosh Ibs Ir Te Am: Object Oriented Programming Using C++
m
Pointer to object
Introduction to Polymorphism
Te a
ir
Types of Polymorphism
Compile Time Polymorphism - Static Binding
Function Overloading
ib S
Operator Overloading
s h
To
Run Time Polymorphism - Dynamic Binding - FUnction Override
Virtual Function
ir Te
• Which of the following operators cannot be overloaded?
ib S
A. .* (Pointer-to-member Operator )
s h
To
B. :: (Scope Resolution Operator)
C. .* (Pointer-to-member Operator )
D. All of the above – correct
b. int func(int);
int func(int);
• Which operator should be used to access the members of the class using object pointer?
a) Dot operator
b) Colon to the member
c) Scope resolution operator
d) Arrow operator -- correct
• A pointer _________________
a) Can point to only one object at a time - correct
b) Can point to more than one objects at a time
c) Can point to only 2 objects at a time
d) Can point to whole class objects at a time
• Pointer to a base class can be initialized with the address of derived class, because of _________
a) derived-to-base implicit conversion for pointers - correct
b) base-to-derived implicit conversion for pointers
a m
Te
c) base-to-base implicit conversion for pointers
ir
d) derived-to-derived implicit conversion for pointers
•
ib
Can pointers to object access the private members of the class? S
a) Yes, always
s h
b) Yes, only if it is only pointer to object
To
c) No, because objects can be referenced from another objects too
d) No, never – correct
• Run time polymorphism is achieved only when a ……………….. Is accessed through a pointer to the base class.
A) static function
B) Real function
C. Member function
D) Virtual function - correct
• Compile time polymorphism in C++ language are
Operator overloading
Function overloading
Function overriding
B Only
A & B – correct
a m
Defining multiple functions with same name in a class is called function overloading
Overloaded function must differ in their order and types of arguments.
ir
Overloaded functions should be preceded with virtual keyword - correct Te
No statement is false
ib S
s h
To
• Following keyword is used before a function in a base class to be overridden in derived class in C++
override
virtual - correct
void
none
ir
d) float
•
ib S
h
Which of the following is the default mode of the opening using the ifstream class?
a) ios::in - correct
b) ios::out
To s
c) ios::app
d) ios::trunc
• Which of the following is the default mode of the opening using the fstream class?
a) ios::in
b) ios::out
c) ios::in|ios::out - correct
d) ios::trunc
• Which of the following is used to move the file pointer to start of a file?
a) ios::beg - correct
b) ios::start
c) ios::cur
d) ios::first
• Which function is used in C++ to get the current position of file pointer in a file?
a) tell_p() - correct
b) get_pos()
a m
c) get_p()
d) tell_pos()
ir Te
ib S
s h
To