# 3i Infotech Placement: Sample Questions 797 - 798 of 1245

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

## Question 797

### Question

MCQ▾

I went to Lucky Duck Casino and in the first game I lost one-third of my money, in the second game I lost half of the rest. If I still have ₹ 1,000. How much money did I have when I arrived at the Casino?

Choice (4)

a.

₹ 1,000

b.

₹ 3,000

c.

₹ 6,000

d.

₹ 2,000

b.

### Explanation

In the first game I lost one third of total money.

In the second game I lost half of the rest.

After second game I am having 1000 ₹

Let the total money I was having in the beginning be ₹ x.

So,

So, I was having ₹ 3000 in the beginning when I arrived at the casino.

## Question 798

Edit

### Describe in Detail

Essay▾

Find the output of the following program

1. `#include <iostream> class fig2d`
2. `{`
3. `    int dim1;`
4. `    int dim2;`
5. `    public:fig2d()`
6. `    {`
7. `        dim1=5;`
8. `        dim2=6;`
9. `    }`
10. `    virtual void operator≪(ostream & rhs);`
11. `};`
12. `void fig2d::operator≪(ostream &rhs)`
13. `{`
14. `    rhs ≪dim1≪" "≪dim2≪" ";`
15. `}`
16. `void main()`
17. `{`
18. `    fig2d obj1; obj1 ≪ cout;`
19. `}`

### Explanation

• In the program
 `class fig2d``{``    int dim1;``    int dim2;``    public:fig2d()``    {``        dim1=5;``        dim2=6;``    }``    virtual void operator ≪ (ostream & rhs);``};` Define the class fig2dDefine the integer variable dim1 and dim2. fig2d () function assigns the value of dim1 = 5 and dim2 = 6 The << operator is overloaded with ostream as arguments. `void fig2d::operator ≪ (ostream &rhs)``{``    rhs ≪ dim1 ≪ ” “ ≪ dim2 ≪ ” “;``}` print the value of dim1 and dim2 `void fig2d::operator ≪ (ostream &rhs)``{``    rhs ≪ dim1 ≪ ” “ ≪ dim2 ≪ ” “;``}` This enables the ‘cout’ to be present at the right-hand-side.Normally, ‘cout’ is implemented as global function, but it doesn՚t mean that ‘cout’ cannot be overloaded as member function.Overloading ≪ as virtual member function is handy when the class in which it is overloaded is inherited, and this becomes available to be overriden.This is as opposed to global friend functions, where friends are not inherited.

Developed by: