Upwork C# Test 2018

Upwork C# Test Answers 2018

40 Answered Test Questions:

1)Which of the following is the correct syntax to group query results using LINQ?
a)var query =
   form student in students
   group student by student. LastName into newGroup
   orderby newGroup. key
b)varquery =
  from sutdent in students
  groupby student. LastName into newGroup
  orderby student. LastName
  select newGroup;
c) var query =
   fom student in students
   groupby student. LastName
   orderby student. LastName
    select student. LastName
d) var query =
    from student in students
    groupings {student. LastName) into newGroup
    select newGroup;

2)What kind of expection is beling throm if Wait(), Pulse() or Pulse All () is called from code that is not within synchronized code?

a)System I/O Exception
b)Divide by Zero Expection
c)Syschronlization lock Expection
d)ALL of the mentioned

3)Wich stream class method can be ussed for the close connection?

a)function close()
b)void close()
c)static close()
d)conenction close()

4)What will be the output of the following Main program in a C# console application (Assume reqried namespaces are included)?

static void Main(sting[] args)
{
string Invalid ="$am$it$";
string sResult = Invalid . Trim (new char [] {'$'});
Console. Writerline (sResult);
Console. ReadLine();
}
a)amit
b)am@am$
c)$am$it$
d)amSit

5)Which of the following is correct in realtion to the above C#.Net code?

Stack st = new Stack ();
 st. Push("Upwork");
 st.Push(9.2);
 st.Push(6);
 st.Push('i');
 st. Push (false);
a)The same Stack collection cannot be used to store dissimilar elements like "Upwork", 9.2, and 6.
b)Stack and never store Boolean values.
c)The fouth call to Push(),"i" should have been used intead of 'i'.
d)To store dissimilar elements in a stack collection, the alternative menthod Pushany Type () should       have been used instead.
e)The above code works fine.


6)consider the following delegate declaration. Which of the  following are TRUE?

delegate void del(int i);
a)On declaring the delegate, a class called del will get created.
b)The signature of del must be the same as the signauture of the method that we intend to call using it.
c)The del clas will be derived form the MulticsDelgate class.
d)The method that can be called using del should not be a static method.
e) The del class will contain a one argument constructor an an Invoke () method.

7)Which of the following is not a realationl operator in C#?

a)<<
b)<=
c)>=
d)<

8)Recursion is a process of defining a____ that calls itself repeatedly in c#?

a)Interface
b)Method
c)Class
d)Constructors

9)What is the difference between "throw ex" and "throw" in C#?

a)"throw ex" will preserve the original stack trace info
b)"throw" will replace the stack trace of the exception with stack trace info of re throw point
c)"throw ex" will replace the stack trace of the exception with stack trace info of re throw point and        "throw" will preserve the original stack trace info
d)None of the above

10)What is the output when following code is executed?

usig system;
using stringBuilder;
namespace Text {
class program {
public static void Main (string [] args0 {
stringBuilder sb = new StringBuilder("hello world in c#);
sb.Insert(4, "example");
COnsole. WriteLine(sb);
Console. ReadLine();
}
 }
}
a)Runtime time error
b)hello world in c# good
c)Compile time error
d)program run but crash

11)What us an Action delegate?

a)An Action is a delegate to a method, that takes zero, one or more input parmeters, but does not            return anything.
b)An Action is a delegate to a method, that takes zero, oner or more input parametres, but always          returns a boolean value.
c)An Action is a delegate to a method, that takes zero, one or more input parameters, but does not          return anthing.
d)An Action is a delegate to a method, that takes one more input parameters, but always returns a          boolean value.

12)C# has support for strongly- typed function poionters via the keyword?

a)delegate
b)variable
c)Class
d)methods

13)choose the namespace in which Expression trees are encapsulated?

a)System. Linq
b)System. Linq. Expressions
c)System. Text
d) System. Collections/ Generic

14)How can a single instance application be created in C#?

a)System. Threading. SingleInstance can be used tot ensure that only one instance of a program can      run at a time.
b)System. Threading. Mutex can be used to ensure that only one instance of a program can run at a         time.
c)Locks can be used to force a C# application to launch a single instance at a time.
d)C# applications cannot be restricted to a single instance.

15)Choose the correct statement about System. Type namespace?

a)Core of the reflection subsystem as it encapsulateds a type
b)Consists of many methods and properties that can be used to obtain information about a type at          runtime.
c)Both a & b
d)Only b
16)Which statement*(s) is/are correct?
a)$ matches the begining of a line.
b) ^ matches the end of a line
c)( opens a group.

17)Which statement is correct about the C#. NET code snippet given below?

Stack st =new Stack();
st. Push("Csharp");
st.Push(7.3);
st.Push(8);
st.Push('b');
st. push(true);
a)Unsimilar elements like "Csharp", 7.3,8 cannot be stored in the same stack collection.
b)Boolean values can never be stored in Stack collection
c)Perfectly worable code
d)All of the mentioned

18)Which of the following is the correct way to call the function Jobs (in i) of the upwork class given below?

class Upwork{
public int Jobs(int i) {
console. Writeline ("Upwork";
return 0;
}
}
a)delegate void del (int i);
  upwork u= new Upwork();
  del d= new del (ref u. Jobs);
  d (10);
b)delegate int del (int i);
  Upwork u= new Upwrok();
  del= new delegate (ref jobs);
  del(10);
c)Upwork u = new Upwork();
   delegate void del = new delegate (ref Jobs);
   del(10);
d)delgate int del (int i);
  del d;
  Upwork u = new Upwork();
  d = new del (ref u. Jobs);
  d(10);

19)In c#, an interface cannot contain which signature?

a)Methods
b)Properties
c)Constructors
d)Indexers and events

20)Which of the following properties related to the network errors is generated by Webexception?

a)Get
b)Send
c)Response
d)Status

21)Which of the following exceptions cannot be thrown by the Delete () function of the FileInfo class (ie. FileInfo. Delete())?

a)IoExcepection
b)Security Exception
c)Unauthorized Acess Exception
d)Invali Operation Exception

22)What is the output when the following code is executed?

static void Main(stirng[] args){
String obj = "sample";
String obj1= "program";
String obj2= obj;
Console. Writeline (obj+ " "+ obj1);
Console. Writeline (s.Length);
COnsole. Readline();
a)Sample program
b)Runtime error
c)Compile time error
d)0

23)How many Bytes are stored by 'Long' Datatype in C#. net?

a)8
b)4
c)2
d)1

24)A class conists of two____ with each interface consisting of ____, ____ and class had no instance data?

a)interfaces, three, methods
b)function, two, methods.
c)variable, one ,methods
d)object,three, methods

25)How can you retrieve a single row with LINQ?

a)Public User Getuser (string userName){
   DBName Data context myDB = new DB name Data context ();
   User user " myDb. User m singles (u, u.User Name "> userName);
   Return user;
   }
b)Public user getuser (string userName){
   DB name Data context myDB = DB name Data Context ();
   User user = myDB. Users. Single (U, u. UserName => User Name);
   Rerturn user;
   }
c)Public usser Getuser (string userName) {
  DB name Data context my DB = new DB Name context ();
  User user => myDB. Users. SIngle (u, u userName = userName);
  Return user;
  }

26)The expression of a lock statemenet must denote a value of a type known to be a?

a)reference type
b)value-type
c)None of the above

27)Which of the following will block the curent thread for a specified number of milliseconds?

a)system. Threading. Thread. Sleep(50);
b)System, Threading. Thread. Splnwait(50);
c)System. Threading. Thread.Vield();
d)None of these.

28)Which of the following code snippets converts an IEnumerable <string> into a string containing comma separted Value?

a)Public static string convertostring (IEnumerable<T> sourve
  {
  return new list<T. (source). Toarary();
  }
b)public static sting Converto string (IEnumerable<T> source)
   {
   return sting. Join(",", source. ToArray ());
   }
c)Public static string Convert to stirig (IEnumerable<T> source)
  {
   return source. To string();
   }
d)Public static string Convert to string (IEnumerable <t> source)
  {
  return string. Join (source. to array());
  }

29)Indentifier is a name can be used to identify a ___, ___,___?

a)variable, function, method
b)class, instance, function
c)Class, variable, function
d)class, method, function

30)static void Main (string{} args) (
    int i= 1, j;
    do
    {
   for (j = 1; ; j++)
   {
   if (i == j 
   Continue;
   Console. Write Line (i + "" +j);
   }
   i++;
   } while (i < 3);
  Console. Readline();
   }
a)Runtime error
b)Compile time error
c)11, 12, 21,13
d)10,11,12,14

31)Consider the following C# code. What would be the value of d?

int? a= 10;
int? b= 11;
int? c= 12;
a = null;
int? d = a ?/ b ?? c;
a)10
b)11
c)12
d)None of the above

32)Which of the following statements is true regarding implementing an intertface using anonymous classes?

a)Anonymous classes cannot implement an interface.
b)Anonymous classes can implement an interface through aspects.
c)Anonymous classes can implement an interface through type casting.
d)Anonymous classes can implement an interface through a dynamic proxy.

33)What is difference between data types "System. String" and "string" in C#?

a)string is a value typem while system. string is a reference type.
b)There is no difference, string is just an alias of the system. string data type.
c)String variable is limeited to storing alphabetic characters, while system. string does not have any limit.
d)None of these.

34)Which of the following keywords is used to manually throw an exception handling?

a)try
b)catch
c)throw
d)finally

35)Which of the following is the correct way to find a string within a string while being case insensitive?

a)stringfirst. contains (stringsecond):
b)stringfirst. toLower (). contains. (stringsecond);
c)stringfirst. contains. (stringsecond. toupper());
d)Stringfirst. indexof (stringsecond, string

36)What is the benefit of using a finally {} block with try- catch statement in C#?

a) The finally block is always executed before the thread is aborted.
b)The finally block is never executed before the thread is aborted.
c)The finally block is never executed after the theread is aborted.
d)the finally block is always executed before ther thread is started.

37)Among the given collections which one is I/O index based?

(choose all that apply).
a)ArrayList
b)bitarray
c)stack
d)Queue

38)Which of the following are types of LINQ?

a)Linq to Objects
b)Linq to SQL
c)LINQ to XML
d)LINQ to Dataset
e)All of the above.

39)Which of the following wil return the absoulute URL.(ie. https://www.something.com/index.aspx)of the requested page (ASP.NET)?

a)Https Context. Current. Request.Url.Absolutepath;
b)Https Context. Current. REquest. URl Absoulet Url;
c)Https Context. Current. Request. URl. Host;
d)Https context. Current. Request. Url. Patha and Query;

40)Which of the follwing will correctly remove duplicates form a list<T>?
a)Int32 index =0;
   while (index < list. Count +1)
   {
  if (list [index] == list [index +1])
   list. Remove At (index);
   else
   index--;
   }
b)List<T> withDupes =Load some Data ();
   list<T>no Dupes = new List <T> (new Hashset <t> (WithDupes));
   with Dupes.
c)List <T> withDupes = Loadd some Data ();
   List <T> no Dupes = with Dupes . Distinct ().Tolist ();
d)List <T> with Dupes = Load some Data ();
  var hs = new Hashset <T> (withhDupes);
  withDupes. All ( x = > hs. add (x) );