logo

CuriousTab

CuriousTab

Discussion


Home C# Programming Control Instructions See What Others Are Saying!
  • Question
  • Which of the following is the incorrect form of Decision Control instruction?


  • Options
  • A.
    if (Condition1) 
    {// Some statement}
  • B.
    if (Condition1) {// Some statement} 
    else {// Some statement}
  • C.
    if (Condition1) {// Some statement} 
    else {// Some statement} 
    else if ( Condition2){//Some statement}
  • D.
    if ( Condition1 ) {// Some statement} 
    else if ( Condition2 ) {// Some statement} 
    else {// Some statement}
  • E.
    if ( Condition1 ) {// Some statement} 
    else if ( Condition2 ) {// Some statement} 
    else if ( Condition3 ) {// Some statement} 
    else {// Some statement}

  • Correct Answer
  • if (Condition1) {// Some statement} 
    else {// Some statement} 
    else if ( Condition2){//Some statement}
     


  • More questions

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

      short s1 = 20;
      short s2 = 400;
      int a;
      a = s1 * s2;


    • Options
    • A. A value 8000 will be assigned to a.
    • B. A negative value will be assigned to a.
    • C. During arithmetic if the result exceeds the high or low value of the range the value wraps around till the other side of the range.
    • D. An error is reported as widening conversion cannot takes place.
    • E. An overflow error will be reported since the result of the multiplication exceeds the range of a Short Integer.
    • Discuss
    • 2. Which of the following is another way to rewrite the code snippet given below?

      int a = 1, b = 2, c = 0;
      if (a < b) c = a;


    • Options
    • A.
      int a = 1, b = 2, c = 0;
      c = a < b ? a : 0;
    • B.
      int a = 1, b = 2, c = 0;
      a < b ? c = a : c = 0;
    • C.
      int a = 1, b = 2, c = 0;
      a < b ? c = a : c = 0 ? 0 : 0;
    • D.
      int a = 1, b = 2, c = 0;
      a < b ? return (c): return (0);
    • E.
      int a = 1, b = 2,c = 0;
      c = a < b : a ? 0;
    • Discuss
    • 3. For the code snippet given below, which of the following statements are valid?

      public class MyContainer<T> where T: IComparabte
      {
          // Insert code here
      }
      1. Class MyContainer requires that it's type argument must implement IComparabte interface.
      2. Type argument of class MyContainer must be IComparabte.
      3. Compiler will report an error for this block of code.
      4. This requirement on type argument is called as constraint.

    • Options
    • A. 1 and 2 Only
    • B. 1, 2 and 3 Only
    • C. 1 and 4 Only
    • D. All of the above
    • E. None of the above
    • Discuss
    • 4. Which of the following statements correctly define .NET Framework?

    • Options
    • A. It is an environment for developing, building, deploying and executing Desktop Applications, Web Applications and Web Services.
    • B. It is an environment for developing, building, deploying and executing only Web Applications.
    • C. It is an environment for developing, building, deploying and executing Distributed Applications.
    • D. It is an environment for developing, building, deploying and executing Web Services.
    • E. It is an environment for development and execution of Windows applications.
    • Discuss
    • 5. Which of the following will be the correct result of the statement b = a in the C#.NET code snippet given below?

      struct Address
      {
          private int plotno;
          private String city; 
      }
      Address a = new Address(); 
      Address b; 
      b = a;

    • Options
    • A. All elements of a will get copied into corresponding elements of b.
    • B. Address stored in a will get copied into b.
    • C. Once assignment is over a will get garbage collected.
    • D. Once assignment is over a will go out of scope, hence will die.
    • E. Address of the first element of a will get copied into b.
    • Discuss
    • 6. Which of the following statements are correct about a HashTable collection?

      1. It is a keyed collection.
      2. It is a ordered collection.
      3. It is an indexed collection.
      4. It implements a IDictionaryEnumerator interface in its inner class.
      5. The key - value pairs present in a HashTable can be accessed using the Keys and Values properties of the inner class that implements the IDictionaryEnumerator interface.

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

          int[] a = {11, 3, 5, 9, 4}; 
      1. The array elements are created on the stack.
      2. Refernce a is created on the stack.
      3. The array elements are created on the heap.
      4. On declaring the array a new array class is created which is derived from System.Array Class.
      5. Whether the array elements are stored in the stack or heap depends upon the size of the array.

    • Options
    • A. 1, 2
    • B. 2, 3, 4
    • C. 2, 3, 5
    • D. 4, 5
    • E. None of these
    • Discuss
    • 8. Which of the following statements are correct about arrays used in C#.NET?

      1. Arrays can be rectangular or jagged.
      2. Rectangular arrays have similar rows stored in adjacent memory locations.
      3. Jagged arrays do not have an access to the methods of System.Array Class.
      4. Rectangular arrays do not have an access to the methods of System.Array Class.
      5. Jagged arrays have dissimilar rows stored in non-adjacent memory locations.

    • Options
    • A. 1, 2
    • B. 1, 3, 5
    • C. 3, 4
    • D. 1, 2, 5
    • E. 4, 5
    • Discuss
    • 9. Which of the following statements are correct?

      1. A switch statement can act on numerical as well as Boolean types.
      2. A switch statement can act on characters, strings and enumerations types.
      3. We cannot declare variables within a case statement if it is not enclosed by { }.
      4. The foreach statement is used to iterate through the collection to get the desired information and should be used to change the contents of the collection to avoid unpredictable side effects.
      5. All of the expressions of the for statement are not optional.

    • Options
    • A. 1, 2
    • B. 2, 3
    • C. 3, 5
    • D. 4, 5
    • E. None of these
    • Discuss
    • 10. Which of the following are the correct ways to define an array of 2 rows and 3 columns?

      1. int[ , ] a;
        a = new int[2, 3]{{7, 1, 3},{2, 9, 6}};
      2. int[ , ] a;
        a = new int[2, 3]{};
      3. int[ , ] a = {{7, 1, 3}, {2, 9,6 }};
      4. int[ , ] a;
        a = new int[1, 2];
      5. int[ , ] a;
        a = new int[1, 2]{{7, 1, 3}, {2, 9, 6}};

    • Options
    • A. 1, 2 , 3
    • B. 1, 3
    • C. 2, 3
    • D. 2, 4, 5
    • E. 4, 5
    • Discuss


    Comments

    There are no comments.

Enter a new Comment