Practice Questions For OOPD 23F 2
Practice Questions For OOPD 23F 2
Monsoon 2023
Final Practice Questions
Student’s Details
Name of the Student:
Roll Number:
Stream:
i n t main ( v o i d ) {
c o u t << checkGreaterThan ( 5 , 6 ) ;
c o u t << checkGreaterThan ( 5 , 3 . 2 ) ;
return 0;
}
1
Roll Number:
2
Roll Number:
A9 What will be the output, and which of the following accesses is going to
be faster and why?
i n t main ( v o i d ) {
v e c t o r <i n t > x ;
c o u t << x . a t ( 1 ) ;
}
i n t main ( v o i d ) {
v e c t o r <i n t > x ;
c o u t << x [ 1 ] ;
}
A10 Consider an STL iterator that requires you to get the elements in reverse
order. Is this possible, and how would you access the next element?
A11 Consider an STL container that has been created. How would you deal-
locate its memory, and handle its memory leaks?
A12 Compare the speed of the following codes:
c l a s s abcd {
public :
int x ;
i n t add ( v a l ) {
return x + val ;
}
i n t o p e r a t o r +( v a l ) {
return x + val ;
}
};
i n t main ( v o i d ) {
abcd a ;
a . x = 5;
c o u t << a . add ( 1 0 ) ;
c o u t << a + 1 0 ;
return 0;
}