You need to add a user to the UserTracker instance

You are developing an application that includes a class named UserTracker. The application includes the
following code segment. (Line numbers are included for reference only.)
01 public delegate void AddUserCallback(int i);
02 public class UserTracker
03 {
04 List<User> users = new List<User>();
05 public void AddUser(string name, AddUserCallback callback)
06 {
07 users.Add(new User(name));
08 callback(users.Count);
09 }10 }
11
12 public class Runner
13 {
14
15 UserTracker tracker = new UserTracker();
16 public void Add(string name)
17 {
18
19 }
20 }
You need to add a user to the UserTracker instance. What should you do?

You are developing an application that includes a class named UserTracker. The application includes the
following code segment. (Line numbers are included for reference only.)
01 public delegate void AddUserCallback(int i);
02 public class UserTracker
03 {
04 List<User> users = new List<User>();
05 public void AddUser(string name, AddUserCallback callback)
06 {
07 users.Add(new User(name));
08 callback(users.Count);
09 }10 }
11
12 public class Runner
13 {
14
15 UserTracker tracker = new UserTracker();
16 public void Add(string name)
17 {
18
19 }
20 }
You need to add a user to the UserTracker instance. What should you do?

A.
Insert the following code segment at line 14:
private static void PrintUserCount(int i)
{

}
Insert the following code segment at line 18:
AddUserCallback callback = PrintUserCount;

B.
Insert the following code segment at line 11:
delegate void AdduserDelegate(userTracker userTracker);
Insert the following code segment at line 18:
AddUserDelegate addDelegate = (userTracker) =>
{

};
addDelegate(tracker);

C.
Insert the following code segment at line 11:
delegate void AddUserDelegate(string name, AddUserCallback callback);
Insert the following code segment at line 18:
AddUserDelegate adder = (i, callback) =>
{

};

D.
Insert the following code segment at line 18:
tracker.AddUser(name, delegate(int i)
{

});



Leave a Reply 0

Your email address will not be published. Required fields are marked *