C# Assessment

C# Assessment

  1. How do you declare a variable in C#?

    a) var x = 10; b) variable x = 10; c) int x = 10;
  2. What is the output of the following C# code snippet?

                            int x = 10;
                            Console.WriteLine(x.GetType());
                            x = 20;
                            Console.WriteLine(x.GetType());
                        
    a) System.Int32 and System.Int32 b) int and int c) int32 and int32
  3. Which C# loop is used to iterate over a range of values?

    a) for b) while c) foreach
  4. In C#, what is used to handle error conditions and exceptions?

    a) try b) catch c) finally
  5. What keyword is used in C# to throw an exception manually?

    a) throw b) try c) exception
  6. Which C# namespace is used for input and output operations?

    a) System.IO b) System.Console c) System.Text
  7. In which programming language is C# primarily implemented?

    a) C++ b) Java c) C#
  8. What will be the output of the following C# code?

                            int[] a = {1, 2, 3};
                            int[] b = a;
                            b[0] = 5;
                            Console.WriteLine(string.Join(" ", a));
                        
    a) 1 2 3 b) 5 2 3 c) 1 5 3