OOPS Interview question

Posted by Sivashankars under OOPS on 3/7/2015 | Points: 10 | Views : 700 | Status : [Member] | Replies : 1
HI All,

Today I had attended a interview for skill set asp.net,c#,Sql

Interview Person asked a question as below

there is a class with two methods.
Public class employee
Public int Getsalary
//Code logic
public string GetEmployee
//Code Logic

Question is
any new client creating object for this class should not have access for getsalary method.
existing client creating object for this class should have access for both methods.

Please tell me how to achieve this.


Posted by: Jitendrasoft09 on: 3/7/2015 [Member] [MVP] Starter | Points: 25


There is a singleton concept in design pattern which satisfy single instance and global access principles. You have to design single pattern to achieve your requirement. Please refer below link for more details-

Jitendra Kumar
If my post helps you, plz mark as an answer.

Sivashankars, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response