logo

CuriousTab

CuriousTab

Discussion


Home C# Programming Namespaces See What Others Are Saying!
  • Question
  • Which of the following statements is correct about namespaces in C#.NET?


  • Options
  • A. Namespaces can be nested only up to level 5.
  • B. A namespace cannot be nested.
  • C. There is no limit on the number of levels while nesting namespaces.
  • D. If namespaces are nested, then it is necessary to use using statement while using the elements of the inner namespace.
  • E. Nesting of namespaces is permitted, provided all the inner namespaces are declared in the same file.

  • Correct Answer
  • There is no limit on the number of levels while nesting namespaces. 


  • More questions

    • 1. Which of the following statements are correct about the C#.NET code snippet given below?

      namespace CuriousTabConsoleApplication
      { 
          class Sample
          { 
              int i, j; 
              public void SetData(int ii, int jj)
              {
                  this.i = ii;
                  this.j = jj 
              } 
          } 
          class MyProgram
          { 
              static void Main(string[ ] args)
              { 
                  Sample s1 = new Sample(); 
                  s1.SetData(10, 2); 
                  Sample s2 = new Sample(); 
                  s2.SetData(5, 10); 
              } 
          } 
      }

    • Options
    • A. The code will not compile since we cannot explicitly use this.
    • B. Using this in this program is necessary to properly set the values in the object.
    • C. The call to SetData() is wrong since we have not explicitly passed the this reference to it.
    • D. The definition of SetData() is wrong since we have not explicitly collected the this reference.
    • E. Contents of this will be different during each call to SetData().
    • Discuss
    • 2. Which of the following are valid .NET CLR JIT performance counters?

      1. Total memory used for JIT compilation
      2. Average memory used for JIT compilation
      3. Number of methods that failed to compile with the standard JIT
      4. Percentage of processor time spent performing JIT compilation
      5. Percentage of memory currently dedicated for JIT compilation

    • Options
    • A. 1, 5
    • B. 3, 4
    • C. 1, 2
    • D. 4, 5
    • Discuss
    • 3. Which of the following statements are correct about a .NET Assembly?

      1. It is the smallest deployable unit.
      2. Each assembly has only one entry point - Main(), WinMain() or DLLMain().
      3. An assembly can be a Shared assembly or a Private assembly.
      4. An assembly can contain only code and data.
      5. An assembly is always in the form of an EXE file.

    • Options
    • A. 1, 2, 3
    • B. 2, 4, 5
    • C. 1, 3, 5
    • D. 1, 2
    • Discuss
    • 4. What will be the output of the C#.NET code snippet given below?

      char ch = Convert.ToChar ('a' | 'b' | 'c'); 
      switch (ch)
      {
          case 'A': 
          case 'a':
          Console.WriteLine ("case A | case a");
          break;
          
          case 'B': 
          case 'b':
          Console.WriteLine ("case B | case b");
          break;
          
          case 'C':
          case 'c':
          case 'D':
          case 'd':
          Console.WriteLine ("case D | case d");
          break;
      }

    • Options
    • A. case A | case a
    • B. case B | case b
    • C. case D | case d
    • D. Compile Error
    • E. No output
    • Discuss
    • 5. Which of the following statements is correct about the C#.NET code snippet given below?

      int i, j, id = 0; switch (id)
      { 
          case i:
              Console.WriteLine("I am in Case i");
              break; 
          
          case j:
              Console.WriteLine("I am in Case j");
              break;
      }

    • Options
    • A. The compiler will report case i and case j as errors since variables cannot be used in cases.
    • B. Compiler will report an error since there is no default case in the switch case statement.
    • C. The code snippet prints the result as "I am in Case i"".
    • D. The code snippet prints the result as "I am in Case j".
    • E. There is no error in the code snippet.
    • Discuss
    • 6. Which of the following statements is correct?

    • Options
    • A. Information is never lost during narrowing conversions.
    • B. The CInteger() function can be used to convert a Single to an Integer.
    • C. Widening conversions take place automatically.
    • D. Assigning an Integer to an Object type is known as Unboxing.
    • E. 3.14 can be treated as Decimal by using it in the form 3.14F.
    • Discuss
    • 7. Which of the following benefits do we get on running managed code under CLR?

      1. Type safety of the code running under CLR is assured.
      2. It is ensured that an application would not access the memory that it is not authorized to access.
      3. It launches separate process for every application running under it.
      4. The resources are Garbage collected.

    • Options
    • A. Only 1 and 2
    • B. Only 2, 3 and 4
    • C. Only 1, 2 and 4
    • D. Only 4
    • E. All of the above
    • Discuss
    • 8. Which of the following statements is correct about the C#.NET code snippet given below?

      namespace CuriousTabConsoleApplication
      { 
          class Sample
          { 
              public int func()
              {
                  return 1;
              } 
              public Single func()
              { 
                  return 2.4f ;
              } 
          } 
          class Program
          { 
              static void Main(string[ ] args)
              {
                  Sample s1 = new Sample(); 
                  int i;
                  i = s1.func(); 
                  Single j; 
                  j = s1.func(); 
              } 
          } 
      }

    • Options
    • A. func() is a valid overloaded function.
    • B. Overloading works only in case of subroutines and not in case of functions.
    • C. func() cannot be considered overloaded because: return value cannot be used to distinguish between two overloaded functions.
    • D. The call to i = s1.func() will assign 1 to i.
    • E. The call j = s1.func() will assign 2.4 to j.
    • Discuss
    • 9. What will be the output of the C#.NET code snippet given below?

      namespace CuriousTabConsoleApplication
      {
          class SampleProgram
          {
              static void Main(string[ ] args)
              {
                  int i, j;
                  int[ , ] arr = new int[ 2, 2 ];
                  for(i = 0; i < 2; ++i)
                  {
                      for(j = 0; j < 2; ++j)
                      {
                          arr[i, j] = i * 17 + i * 17;
                          Console.Write(arr[ i, j ] + " ");
                      }
                  }
              }
          }
      }

    • Options
    • A. 0 0 34 34
    • B. 0 0 17 17
    • C. 0 0 0 0
    • D. 17 17 0 0
    • E. 34 34 0 0
    • Discuss
    • 10. Which of the following is the correct way to rewrite the following C#.NET code snippet given below?

      int i = 0; 
      do
      {
          Console.WriteLine(i);
          i+ = 1; 
      } while (i <= 10);

    • Options
    • A.
      int i = 0; 
      do
      {
          Console.WriteLine(i);
      } until (i <= 10);
    • B.
      int i;
      for (i = 0; i <= 10 ; i++)
          Console.WriteLine(i);
    • C.
      int i = 0; 
      while (i <= 11)
      {
          Console.WriteLine(i);
          i += 1; 
      }
    • D.
      int i = 0;
      do while ( i <= 10)
      {
          Console.WriteLine(i); 
          i += 1;
      }
    • E.
      int i = 0;
      do until (i <= 10)
      {
          Console.WriteLine(i);
          i+=1; 
      }
    • Discuss


    Comments

    There are no comments.

Enter a new Comment