TCS Placement: Sample Questions 487 - 488 of 502

Get unlimited access to the best preparation resource for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 487

Question

MCQ▾

Which of the following cannot be friend?

Choices

Choice (4)

a.

Function

b.

Operator function

c.

Class

d.

Object

Answer

d.

Explanation

  • An object cannot be friend.
  • An object is an instance of a Class.
  • When a class is defined, no memory is allocated but when it is instantiated (i.e.. an object is created) memory is allocated.
  • “Friend” is a compile time construct while “Objects” exist at run time.
  • A class is defined in C ++ using keyword class followed by the name of class.
  • When a class is defined, only the specification for the object is defined; no memory or storage is allocated. To use the data and access functions defined in the class objects have to be created.
  • Syntax: ClassName ObjectName;
Given the Image is Define the Class and Object Example

Question 488

Edit

Write in Short

Short Answer▾

A spends 90 % of his salary and B spends 85 % of his salary. But savings of both are equal. Find the income of B, if sum of their incomes is ₹ 5000.

Explanation

As A is spending 90 % of his salary, his savings of his salary. ‎As B is spending 85 % of his salary, his savings of his salary. ‎Given that, both are saving equal amount. ‎Therefore, 10 % of A՚s salary = 15 % of B՚s salary‎Therefore,

So,

So,

We are asked to find the salary of B.

Sum of their income is ₹ 5000, i.e..

Hence, B՚s income is ₹ 2000.

Developed by: