Question: Please help with these C# questios I will thumbs up in rating !!! 1) Given the following array is defined: string[] colors = { green,

Please help with these C# questios

I will thumbs up in rating !!!

1) Given the following array is defined:

string[] colors = { "green", "brown", "blue", "red", "purple" };

What's the output from the following in C#?

var query = from c in colors where c.Length == 4 select c;

foreach (var element in query) Console.WriteLine (element);

A) purple B) red C) blue D) green, brown E) green, brown, blue, red, purple F) purple, red, blue, brown, green

2) What is a Nullable type in C#?

A) It allows assignment of null to reference type. B) It allows assignment of null to value type. C) It allows assignment of null to static class. D) None of the above.

3) What will be the output of the following code?

{ try { int []a = {1, 2, 3, 4, 5}; for (int i = 0; i < 5; ++i) Console.WriteLine(a[i]); int x = (1 / Convert.ToInt32(0)); } catch(IndexOutOfRangeException e) { Console.WriteLine("A"); } catch(ArithmeticException e) { Console.WriteLine("B"); } Console.ReadLine(); }

A) 1234 B) 12345 C) 12345B D) no output

4) What will be the output of the following code?

{ int sum = 10; try { int i; for (i = -1; i < 3; ++i) sum = (sum / i); } catch (ArithmeticException e) { Console.WriteLine("0"); } Console.WriteLine(sum); Console.ReadLine(); }

A)0 B)0 5 C)0 -10 D) -1 0 1 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!