For each of the following statements, select Yes if the statement is true. Otherwise, select No.
Answer:
17 Comments on “For each of the following statements, select Yes if the statement is true…”
Dhruvsays:
The answer should be
No
Yes
Yes
1
1
Dhruvsays:
I take it back. The answer given is correct.
It should be
Yes
No
No
0
2
koernomopsays:
Answer is
Yes – user.UserGroup = Group.Users | Group.Managers;
// see FlagsAttribute
Yes – user.UserGroup = Group.Administrators;
var b = user.UserGroup == Group.Administrators;
// b is true
Yes – user.UserGroup = Group.Supervisors;
var c = user.UserGroup < Group.Administrators;
// c is true because 2 < 8
1
0
karfiksays:
Three yeses are correct. Tried with simple console application.
0
0
Farhatsays:
How can all answer are correct?
can you send me the console code?
0
0
Mr Dsays:
Yes
Yes
Yes
Tested by console
3
0
宾宾says:
三个答案都是正确的。
1
0
ASVsays:
No,
Yes,
Yes.
0
1
ASVsays:
Yes, Yes, Yes.
2
0
Glebsays:
1) Yes, because Group is enum with FlagAttribute
2) Yes, because only Administrator = 8 and 8 == 8 is true
3) Yes, becaues only Supervisor = 2 and 2 < 8 is true
2
0
Mahbubsays:
YES -> this one is confusing. user can be part of new group with enum 3(Group.Users | Group.Supervisors)
YES
YES
1
0
Farhatsays:
Please can any one give the correct answer to me?
Above comments are creating confusing.
0
0
Jiping Wangsays:
Yes,
Yes,
Yes,
all checked in Visual Studio 2015.
0
0
Elvissays:
I typed this code for check whether first case works . In this case it`s not working. The code output NO. Other cases are YES .
public class User
{
public Group UserGroup { get; set; }
}
[FlagsAttribute()]
public enum Group
{
Users=1,
Supervisors=2,
Managers=4,
Administrators=8
}
class Program
{
static void Main(string[] args)
{
// The first case
User us1 = new User();
us1.UserGroup = Group.Supervisors | Group.Users;
bool checkVar = us1.UserGroup==Group.Supervisors;
if (checkVar)
{
Console.WriteLine(“YES”);
}
else { Console.WriteLine(“NO”); }
//The second case
User us2 = new User();
us2.UserGroup = Group.Administrators;
if (us2.UserGroup == Group.Administrators)
{
Console.WriteLine(“YES”);
}
else { Console.WriteLine(“NO”); }
// The third case
User us3 = new User();
us3.UserGroup = Group.Supervisors;
if (us3.UserGroup < Group.Administrators)
{
Console.WriteLine("YES");
}
else { Console.WriteLine("NO"); }
Console.ReadLine();
}
}
0
0
Artemsays:
For true test first case you must check
if(us1.UserGroup == Group.Supervisors && us1.UserGroup == Group.Users)
but result not changed.
0
0
harshsays:
Tested with the visiual studio :
User u = new User();
u.UserGroup = Group.Administrator | Group.Users;
Console.WriteLine((u.UserGroup == Group.Administrator).ToString());
User u1 = new User();
u1.UserGroup = Group.Administrator;
Console.WriteLine(u1.UserGroup==Group.Administrator);
User u2 = new User();
u2.UserGroup = Group.Super;
Console.WriteLine(u2.UserGroup< Group.Administrator);
Console.Read();
public class User
{
public UserGroup Group;
}
public class Flags
{
public static void Main(string[] args)
{
User usr = new User()
{
Group = UserGroup.Administrator
};
if (usr.Group == UserGroup.Administrator)
{
Console.WriteLine(“User1 is an administrator”);
}
User usr2 = new User() { Group = UserGroup.Supervisor };
if (usr2.Group < UserGroup.Administrator)
{
Console.WriteLine("User2 is an Supervisor");
}
User usr3 = new User() { Group = UserGroup.Administrator | UserGroup.manager };
if (usr3.Group.HasFlag( UserGroup.manager))
{
Console.WriteLine("User3 is an Manager");
}
The answer should be
No
Yes
Yes
1
1
I take it back. The answer given is correct.
It should be
Yes
No
No
0
2
Answer is
Yes – user.UserGroup = Group.Users | Group.Managers;
// see FlagsAttribute
Yes – user.UserGroup = Group.Administrators;
var b = user.UserGroup == Group.Administrators;
// b is true
Yes – user.UserGroup = Group.Supervisors;
var c = user.UserGroup < Group.Administrators;
// c is true because 2 < 8
1
0
Three yeses are correct. Tried with simple console application.
0
0
How can all answer are correct?
can you send me the console code?
0
0
Yes
Yes
Yes
Tested by console
3
0
三个答案都是正确的。
1
0
No,
Yes,
Yes.
0
1
Yes, Yes, Yes.
2
0
1) Yes, because Group is enum with FlagAttribute
2) Yes, because only Administrator = 8 and 8 == 8 is true
3) Yes, becaues only Supervisor = 2 and 2 < 8 is true
2
0
YES -> this one is confusing. user can be part of new group with enum 3(Group.Users | Group.Supervisors)
YES
YES
1
0
Please can any one give the correct answer to me?
Above comments are creating confusing.
0
0
Yes,
Yes,
Yes,
all checked in Visual Studio 2015.
0
0
I typed this code for check whether first case works . In this case it`s not working. The code output NO. Other cases are YES .
public class User
{
public Group UserGroup { get; set; }
}
[FlagsAttribute()]
public enum Group
{
Users=1,
Supervisors=2,
Managers=4,
Administrators=8
}
class Program
{
static void Main(string[] args)
{
// The first case
User us1 = new User();
us1.UserGroup = Group.Supervisors | Group.Users;
bool checkVar = us1.UserGroup==Group.Supervisors;
if (checkVar)
{
Console.WriteLine(“YES”);
}
else { Console.WriteLine(“NO”); }
//The second case
User us2 = new User();
us2.UserGroup = Group.Administrators;
if (us2.UserGroup == Group.Administrators)
{
Console.WriteLine(“YES”);
}
else { Console.WriteLine(“NO”); }
// The third case
User us3 = new User();
us3.UserGroup = Group.Supervisors;
if (us3.UserGroup < Group.Administrators)
{
Console.WriteLine("YES");
}
else { Console.WriteLine("NO"); }
Console.ReadLine();
}
}
0
0
For true test first case you must check
if(us1.UserGroup == Group.Supervisors && us1.UserGroup == Group.Users)
but result not changed.
0
0
Tested with the visiual studio :
User u = new User();
u.UserGroup = Group.Administrator | Group.Users;
Console.WriteLine((u.UserGroup == Group.Administrator).ToString());
User u1 = new User();
u1.UserGroup = Group.Administrator;
Console.WriteLine(u1.UserGroup==Group.Administrator);
User u2 = new User();
u2.UserGroup = Group.Super;
Console.WriteLine(u2.UserGroup< Group.Administrator);
Console.Read();
Got answer :
False
True
True
means
NO
YES
YES
0
0
Yes, Yes, Yes
using System;
[Flags]
public enum UserGroup
{
Users = 1,
Supervisor = 2,
manager = 4,
Administrator = 8
}
public class User
{
public UserGroup Group;
}
public class Flags
{
public static void Main(string[] args)
{
User usr = new User()
{
Group = UserGroup.Administrator
};
if (usr.Group == UserGroup.Administrator)
{
Console.WriteLine(“User1 is an administrator”);
}
User usr2 = new User() { Group = UserGroup.Supervisor };
if (usr2.Group < UserGroup.Administrator)
{
Console.WriteLine("User2 is an Supervisor");
}
User usr3 = new User() { Group = UserGroup.Administrator | UserGroup.manager };
if (usr3.Group.HasFlag( UserGroup.manager))
{
Console.WriteLine("User3 is an Manager");
}
Console.ReadKey();
}
}
0
0