logo

CuriousTab

CuriousTab

Discussion


Home C# Programming Constructors See What Others Are Saying!
  • Question
  • 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.

  • Correct Answer
  • func() cannot be considered overloaded because: return value cannot be used to distinguish between two overloaded functions. 


  • More questions

    • 1. Which of the following code snippets are the correct way to determine whether a is Odd or Even?

      1. int a;
        String res; 
        if (a % 2 == 0)
            res = "Even"; 
        else 
            res = "Odd";
      2. int a; 
        String res; 
        if (a Mod 2 == 0) 
            res = "Even"; 
        else
            res = "Odd";
      3. int a;
        Console.WriteLine(a Mod 2 == 0? "Even": "Odd");
      4. int a; 
        String res;
        a % 2 == 0? res = "Even" : res = "Odd";
        Console.WriteLine(res);

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

      int a = 10, b = 20, c = 30; 
      int res = a < b? a < c? c : a : b; 
      Console.WriteLine(res);

    • Options
    • A. 10
    • B. 20
    • C. 30
    • D. Compile Error / Syntax Error
    • Discuss
    • 3. How can you prevent inheritance from a class in C#.NET?

    • Options
    • A. Declare the class as shadows.
    • B. Declare the class as overloads.
    • C. Declare the class as sealed.
    • D. Declare the class as suppress.
    • E. Declare the class as override.
    • Discuss
    • 4. There is no private or protected inheritance in C#.NET.

    • Options
    • A. True
    • B. False
    • Discuss
    • 5. Which of the following is NOT an Arithmetic operator in C#.NET?

    • Options
    • A. **
    • B. +
    • C. /
    • D. %
    • E. *
    • Discuss
    • 6. The space required for structure variables is allocated on stack.

    • Options
    • A. True
    • B. False
    • Discuss
    • 7. Is it possible to invoke Garbage Collector explicitly?

    • Options
    • A. Yes
    • B. No
    • Discuss
    • 8. It possible to create a custom attribute that can be applied only to specific programming element(s) like ____ .

    • Options
    • A. Classes
    • B. Methods
    • C. Classes and Methods
    • D. Classes, Methods and Member-Variables
    • Discuss
    • 9. C#.NET structures are always value types.

    • Options
    • A. True
    • B. False
    • Discuss
    • 10. What does the following C#.NET code snippet will print?

      int i = 0, j = 0; 
      
      label:
          i++;
          j+=i;
      if (i < 10)
      {
          Console.Write(i +" ");
          goto label; 
      }

    • Options
    • A. Prints 1 to 9
    • B. Prints 0 to 8
    • C. Prints 2 to 8
    • D. Prints 2 to 9
    • E. Compile error at label:.
    • Discuss


    Comments

    There are no comments.

Enter a new Comment