logo

CuriousTab

CuriousTab

Discussion


Home C# Programming Attributes See What Others Are Saying!
  • Question
  • Which of the following CANNOT be a target for a custom attribute?


  • Options
  • A. Enum
  • B. Event
  • C. Delegate
  • D. Interface
  • E. Namespace

  • Correct Answer
  • Namespace 


  • More questions

    • 1. Which of the following is correct way to convert a String to an int?

      1. String s = "123"; 
        int i;
        i = (int)s;
      2. String s = "123";
        int i;
        i = int.Parse(s);
      3. String s = "123"; 
        int i;
        i = Int32.Parse(s);
      4. String s = "123"; 
        int i;
        i = Convert.ToInt32(s);
      5. String s = "123"; 
        int i;
        i = CInt(s);

    • Options
    • A. 1, 3, 5
    • B. 2, 4
    • C. 3, 5
    • D. 2, 3, 4
    • Discuss
    • 2. How will you complete the foreach loop in the C#.NET code snippet given below such that it correctly prints all elements of the array a?

          int[][]a = new int[2][];
          a[0] = new int[4]{6, 1 ,4, 3};
          a[1] = new int[3]{9, 2, 7}; 
          foreach (int[ ] i in a)
          {
              /* Add loop here */
              Console.Write(j + " ");
              Console.WriteLine(); 
          }

    • Options
    • A. foreach (int j = 1; j < a(0).GetUpperBound; j++)
    • B. foreach (int j = 1; j < a.GetUpperBound (0); j++)
    • C. foreach (int j in a.Length)
    • D. foreach (int j in i)
    • E. foreach (int j in a.Length -1)
    • Discuss
    • 3. An Account class has a property called accountNo and acc is a reference to a bank object and we want the C#.NET code snippet given below to work. Which of the following options will ensure this functionality?

      acc.accountNo = 10; 
      Console.WriteLine(acc.accountNo);

    • Options
    • A. Declare accountNo property with both get and set accessors.
    • B. Declare accountNo property with only get accessor.
    • C. Declare accountNo property with get, set and normal accessors.
    • D. Declare accountNo property with only set accessor.
    • E. None of the above
    • Discuss
    • 4. Which of the following statements is correct about an interface?

    • Options
    • A. One interface can be implemented in another interface.
    • B. An interface can be implemented by multiple classes in the same program.
    • C. A class that implements an interface can explicitly implement members of that interface.
    • D. The functions declared in an interface have a body.
    • Discuss
    • 5. Which of the following statements is correct about the C#.NET code snippet given below?

      class Trial
      { 
          int i;
          Decimal d;
      }
      struct Sample
      {
          private int x;
          private Single y;
          private Trial z;
      }
      Sample ss = new Sample();

    • Options
    • A. ss will be created on the heap.
    • B. Trial object referred by z will be created on the stack.
    • C. z will be created on the heap.
    • D. Both ss and z will be created on the heap.
    • E. ss will be created on the stack.
    • Discuss
    • 6. Which of the following snippets are the correct way to convert a Single into a String?

      1. Single f = 9.8f; 
        String s;
        s = (String) (f);
      2. Single f = 9.8f; 
        String s;
        s = Convert.ToString(f);
      3. Single f = 9.8f; 
        String s;
        s = f.ToString();
      4. Single f = 9.8f; 
        String s;
        s = Clnt(f);
      5. Single f = 9.8f; 
        String s;
        s = CString(f);

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

      int num = 1, z = 5;
      
      if (!(num <= 0))
          Console.WriteLine( ++num + z++ + " " + ++z ); 
      else
          Console.WriteLine( --num + z-- + " " + --z ); 

    • Options
    • A. 5 6
    • B. 6 5
    • C. 6 6
    • D. 7 7
    • Discuss
    • 8. Which of the following statements is correct?

    • Options
    • A. When used as a modifier, the new keyword explicitly hides a member inherited from a base class.
    • B. Operator overloading works in different ways for structures and classes.
    • C. It is not necessary that all operator overloads are static methods of the class.
    • D. The cast operator can be overloaded.
    • Discuss
    • 9. Which of the following is the correct ways to set a value 3.14 in a variable pi such that it cannot be modified?

    • Options
    • A. float pi = 3.14F;
    • B. #define pi 3.14F;
    • C. const float pi = 3.14F;
    • D. const float pi; pi = 3.14F;
    • E. pi = 3.14F;
    • Discuss
    • 10. Which of the following statements is correct about the C#.NET program given below if a value "ABCD" is input to it?

      using System;
      namespace CuriousTabConsoleApplication
      {
          class MyProgram
          {
              static void Main(string[] args)
              {
                  int index; 
                  int vat = 88;
                  int[] a = new int(5];
                  try
                  {
                      Console.Write("Enter a number: ");
                      index = Convert.Toint32(Console.ReadLine());
                      a[index] = val;
                  }
                  catch(Exception e)
                  {
                      Console.Write("Exception occurred");
                  }
                  Console.Write("Remaining program");
              }
          }
      }

    • Options
    • A. It will output: Exception occurred
    • B. It will output: Remaining program
    • C. It will output: Remaining program Exception occurred
    • D. It will output: Exception occurred Remaining program
    • E. The value 88 will get assigned to a[0].
    • Discuss


    Comments

    There are no comments.

Enter a new Comment