CPP

CPP

Objects has 10 Questions
Where does the object is created?

class
constructor
destructor
attributes
How to access the object in the class?

scope resolution operator
ternary operator
direct member access operator
none of the mentioned
Which of these following members are not accessed by using direct member access operator?

public
private
protected
Both b & c
What is the output of the following program?
  1.     #include 
  2.     using namespace std;
  3.     class Box
  4.     {
  5.         public :
  6.         double length;
  7.         double breadth;
  8.         double height;
  9.     };
  10.     int main( )
  11.     {
  12.         Box Box1;
  13.         double volume;
  14.         Box1.height = 5;
  15.         Box1.length = 6;
  16.         Box1.breadth = 7.1;
  17.         volume = Box1.height * Box1.length * Box1.breadth;
  18.         cout << "Volume of Box1 : " << volume <<endl;
  19.         return 0;
  20.     }

210
213
215
217
What is the output of the program?
  1.     #include 
  2.     using namespace std;
  3.     class Rect
  4.     {
  5.         int x, y;
  6.         public:
  7.         void set_values (int,int);
  8.         int area ()
  9.         {
  10.             return (x * y);
  11.         }
  12.     };
  13.     void Rect::set_values (int a, int b) {
  14.         x = a;
  15.         y = b;
  16.     }
  17.     int main ()
  18.     {
  19.         Rect recta, rectb;
  20.         recta.set_values (5, 6);
  21.         rectb.set_values (7, 6);
  22.         cout << "recta area: " << recta.area();
  23.         cout << "rectb area: " << rectb.area();
  24.         return 0;
  25.     }

recta area: 30 rectb area: 42
recta area: 20 rectb area: 34
recta area: 30 rectb area: 21
none of the mentioned
Pick out the other definition of objects.

member of the class
associate of the class
attribute of the class
instance of the class
How many objects can present in a single class?

1
2
3
as many as possible
What is the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     class sample
  4.     {
  5.         private:
  6.         int var;
  7.         public:
  8.         void input()
  9.         {
  10.            cout << var;
  11.         }
  12.         void output()
  13.         {
  14.            cout << "Variable entered is ";
  15.            cout << var << "\n";
  16.         }
  17.     };
  18.     int main()
  19.     {
  20.         sample object;
  21.         object.input();
  22.         object.output();
  23.         object.var();
  24.         return 0;
  25.     }

Enter an integer 5 Variable entered is 5
runtime error
error
none of the mentioned
Which special character is used to mark the end of class?

;
:
#
$
What is the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     class number
  4.     {
  5.         int i;
  6.         public:
  7.         int geti();
  8.         void puti(int j);
  9.     };
  10.     int number::geti()
  11.     {
  12.         return i;
  13.     }
  14.     void number::puti(int j)
  15.     {
  16.         i = j;
  17.     }
  18.     int main()
  19.     {
  20.         number s;
  21.         s.puti(10);
  22.         cout << s.geti( );
  23.         return 0;
  24.     }

10
11
20
22