Professional Documents
Culture Documents
OOPS and C++
OOPS and C++
Choice a
Choice b
Choice c
Choice d
2
1
4
3
The data member of strucure are by default public and the data
members of the class by default private
Choi
ce b
Choi
ce c
Choi
ce d
Choi
ce b
Choi
ce c
Choi
ce d
Data members
Choice a
member function
Choice b
Both i and ii
Choice c
Choice d
Choice a
By public declaration
Choice b
By protected declaration
Choice c
By friend declaration
Choice d
Choic
eb
Choic
ec
Choic
ed
Choi
ce b
Choi
ce c
Choi
ce d
Choice
a
Choice
b
Choice
c
Choice
d
Choice a
Protected
Choice b
Public
Choice c
Choice d
Choice a
Choice b
Choice c
Choice d
Choice a
By address
Choice b
By reference
Choice c
Choice d
Choice b
Choice c
Choice d
destructor
Choic
eb
member function
Choic
ec
constructor
Choic
ed
Choice a
false , false
Choice b
false , true
Choice c
true , true
Choice d
int
void
class
None of the above
Choice b
Choice c
Both ( a ) and ( b )
Choice d
true
false
may be in certain cases only
None of the above
Operator overloading
Operator classification
Operator initialization
All of the above
[20] While overloading the operator, the operator function must be eithe
________________ .
Choice a
Choice b
Choice c
Choice d
static function
member function or friend function
inline function
overloaded funtion
Assignment operator =
Choice b
Choice c
Choice d
new
delete
?:
All of the above.
Choice a
number :100
cost :299.95
Choice b
number :200
cost :175.5
Both of the above
Choice c
Choice d
Choice d
Choice b
Choice c
Choice d
object number:1
object number:2
object number:3
count:3
object number:3
object number:3
object number:3
count:3
object number:2
object number:2
object number:2
count:0
None of the above
67
88
Both of the above
77
{
a = 25 ; b = 40 ;
}
friend float mean ( sample ) ;
};
float mean ( sample s )
{
return float ( s.a + s.b ) / 2.0 ;
}
void main( )
{
sample X ;
X.setvalue ( ) ;
cout << "Mean Value - " << mean ( X ) << endl ;
}
What would be the output of the above program?
Choice a
Choice b
Choice c
Choice d
Mean Value - 25
Mean Value - 40
Mean Value - 32.5
Mean Value - 65
public :
void Display ( void )
{
cout << x << y << sum <<endl ;
}
};
void main ( void )
{
Sample p( 10 , 20 ) ;
p.Display ( ) ;
}
What would be the output of the above program ?
Choice a
Choice b
Choice c
Choice d
10 20 30
10 2 12
10 22 32
Compile time Error
y=b;
}
friend int sum ( M m ) ;
};
int sum ( M m )
{
int M :: *px = &M :: x ;
int M :: *py = &M :: y ;
M *pm = &m ;
int S = m.px + pm->*py ;
return S ;
}
void main( )
{
Mn;
void ( M :: *pf ) ( int, int ) = &M :: set_xy ;
( n.*pf ) ( 10, 20 ) ;
cout << "SUM = " << sum ( n ) << endl ;
M *op = &n ;
( op -> *pf ) ( 30, 40 ) ;
cout << "SUM = " << sum ( n ) << endl ;
}
What would happen when the above code would get executed?
Choice
a
Choice
b
Choice
c
Choice
d
};
class ABC
{
int a ;
public:
void setvalue ( int i )
{
a=i;
}
friend void max ( XYZ, ABC ) ;
};
void max ( XYZ m, ABC n )
{
if ( m.x >= n.a )
cout << m.x ;
else
cout << n.a ;
}
void main( )
{
ABC abc ;
abc.setvalue ( 10 ) ;
XYZ xyz ;
xyz.setvalue ( 20 ) ;
max ( xyz, abc ) ;
}
What would be the output of the above program?
Choice a
Choice b
Choice c
Choice d
10
20
10 20
15