= -10) i -= 4; else break; } 20"> = -10) i -= 4; else break; } 20">
logo

CuriousTab

CuriousTab

Discussion


Home C# Programming Control Instructions See What Others Are Saying!
  • Question
  • Which of the following is the correct output for the C#.NET program given below?

    int i = 20 ;
    for( ; ; )
    {
        Console.Write(i + " "); 
        if (i >= -10)
            i -= 4; 
        else 
            break;
    }


  • Options
  • A. 20 16 12 84 0 -4 -8
  • B. 20 16 12 8 4 0
  • C. 20 16 12 8 4 0 -4 -8 -12
  • D. 16 12 8 4 0
  • E. 16 8 0 -8

  • Correct Answer
  • 20 16 12 8 4 0 -4 -8 -12 


  • 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