srini


{ City }
< Country > india
* Profession * software engineer
User No # 3675
Total Questions Posted # 0
Total Answers Posted # 3

Total Answers Posted for My Questions # 0
Total Views for My Questions # 0

Users Marked my Answers as Correct # 20
Users Marked my Answers as Wrong # 24
Questions / { srini }
Questions Answers Category Views Company eMail




Answers / { srini }

Question { Ness Technologies, 20789 }

How would you stop a class from class from being derived or
inherited.


Answer

#define DO_NOT_DERIVE(T) \
class NoDerive_##T { \
friend class T;
\
NoDerive_##T() {}
\
NoDerive_##T(const NoDerive_##T&) {} \
};
#define stopderiving(T) private virtual NoDerive_##T

when we derive from any class, the constructor needs to be
called, since here constructor of NoDerive calss is
private, it cannot be derived. And friendship cannot be
inherited.
usage
class finalclass : stopderiving (finalclass)
{
....
};

the other possible solution for this is making the default
constructor private.

Is This Answer Correct ?    4 Yes 1 No

Question { IBM, 25168 }

We have a scale and 7 balls. 1 ball is heavier than all the
rest. How to determine the heaviest ball with only 3
possible weighing attempts?


Answer

let a,b,c,d,e,f,g be the 7 balls,
group them
a and b group 1
b and c group 2 and others one group
weigh group 1 against group 2
if they are not equal weigh the individual balls with
respect to each other

if they are not equal(group 1 is not equal to group 2)
weigh e against f, if they are not equal heaviest among
them is ur answer else g is the answer.

Is This Answer Correct ?    6 Yes 22 No


Question { IBM, 9609 }

Should you protect the global data in threads? Why or why
not?


Answer

Global datas needs to be protected in threads since threads
share address space with each other.

Is This Answer Correct ?    10 Yes 1 No