C/ Sample Test,Sample questions

Question:
 
How many values is a subroutine capable of returning?

1. Depends upon how many params arguments does it use.

2.Any number of values.

3.Depends upon how many ref arguments does it use.

4.0

Posted Date:-2021-02-24 10:36:42


Question:
  
How many values is a function capable of returning?

1.1

2.0

3.Depends upon how many params arguments does it use.

4.Any number of values.

Posted Date:-2021-02-24 10:36:42


Question:
What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[ ] args)
        {
            int i = 10;
            double d = 34.340;
            fun(i);
            fun(d);
        }
        static void fun(double d)
        {
            Console.WriteLine(d + " ");
        }
    }
}

1.10.000000 34.340000

2.10 34

3.10 34.340

4. 10 34.34

Posted Date:-2021-02-24 10:36:42


Question:
What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[ ] args)
        {
            int i = 5;
            int j;
            fun1(ref i);
            fun2(out j);
            Console.WriteLine(i + ", " + j);
        }
        static void funl(ref int x)
        {
            x = x * x;
        }
        static void fun2(out int x)
        {
            x = 6; 
            x = x * x; 
        }
    }
}

1. 5, 6

2.5, 36

3. 25, 36

4. 25, 0

Posted Date:-2021-02-24 10:36:42


Question:
What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[ ] args)
        {
            int i;
            int res = fun(out i);
            Console.WriteLine(res);
        }
        static int fun (out int i)
        {
            int s = 1;
            i = 7;
            for(int j = 1; j <= i; j++)
            {
                s = s * j;
            }
            return s;
        } 
    } 
}

1.1

2.7

3.8

4.5040

Posted Date:-2021-02-24 10:36:42


Question:
What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{
    class SampleProgram
    {
        static void Main(string[ ] args)
        {
            object[] o = new object[] {"1", 4.0, "India", 'B'};
            fun (o);
        }
        static void fun (params object[] obj)
        {
            for (int i = 0; i < obj.Length-1; i++)
            Console.Write(obj[i] + " ");
        }
    }
}

1.1 4.0 India B

2.1 4.0 India

3. 1 4 India

4. 1 India B

Posted Date:-2021-02-24 10:36:42


Question:
What will be the output of the C#.NET code snippet given below?

namespace IndiabixConsoleApplication
{ 
    class SampleProgram
    { 
        static void Main(string[] args)
        { 
            int[]arr = newint[]{ 1, 2, 3, 4, 5 }; 
            fun(ref arr);
        }
        static void fun(ref int[] a)
        { 
            for (int i = 0; i < a.Length; i++)
            { 
                a[i] = a[i] * 5; 
                Console.Write(a[ i ] + " "); 
            } 
        } 
    } 
}

1. 1 2 3 4 5

2.6 7 8 9 10

3.5 10 15 20 25

4.5 25 125 625 3125

Posted Date:-2021-02-24 10:36:42


Question:
Which of the following CANNOT occur multiple number of times in a program?

1.namespace

2.Entrypoint

3.Class

4.Function

Posted Date:-2021-02-24 10:36:42


Question:
Which of the following statements are correct about functions and subroutines used in C#.NET?

A function cannot be called from a subroutine.
The ref keyword causes arguments to be passed by reference.
While using ref keyword any changes made to the parameter in the method will be reflected in that variable when control passes back to the calling method.
A subroutine cannot be called from a function.
Functions and subroutines can be called recursively.

1.1, 2, 4

2.2, 3, 5

3.3, 5

4. 4, 5

Posted Date:-2021-02-24 10:36:42


Question:
Which of the following statements are correct about functions used in C#.NET?

Function definitions cannot be nested.
Functions can be called recursively.
If we do not return a value from a function then a value -1 gets returned.
To return the control from middle of a function exit function should be used.
Function calls can be nested.

1.1, 2, 5

2. 2, 3, 5

3.2, 3

4.4, 5

Posted Date:-2021-02-24 10:36:42


Question:
Which of the following statements are correct about subroutines used in C#.NET?

If we do not return a value from a subroutine then a value -1 gets returned.
Subroutine definitions cannot be nested.
Subroutine can be called recursively.
To return the control from middle of a subroutine exit subroutine should be used.
Subroutine calls can be nested.

1.1, 2, 3

2.2, 3, 5

3.3, 5

4.3, 4

Posted Date:-2021-02-24 10:36:42


Question:
Which of the following statements are correct?

An argument passed to a ref parameter need not be initialized first.
Variables passed as out arguments need to be initialized prior to being passed.
Argument that uses params keyword must be the last argument of variable argument list of a method.
Pass by reference eliminates the overhead of copying large data items.
To use a ref parameter only the calling method must explicitly use the ref keyword.

1.1,2

2.2,3

3.3,4

4.4,5

Posted Date:-2021-02-24 10:36:42


Question:
Which of the following statements are correct?

C# allows a function to have arguments with default values.
C# allows a function to have variable number of arguments.
Omitting the return value type in method definition results into an exception.
Redefining a method parameter in the method's body causes an exception.
params is used to specify the syntax for a function with variable number of arguments.

1.1, 3, 5

2.3, 4, 5

3.2, 5

4.4, 5

Posted Date:-2021-02-24 10:36:42


Question:
Which of the following will be the correct output for the C#.NET program given below?

namespace IndiabixConsoleApplication
{ 
    class SampleProgram
    { 
        static void Main(string[] args)
        {
            int a = 5; 
            int s = 0, c = 0;
            Proc(a, ref s, ref c);
            Console.WriteLine(s + " " + c);
        }
        static void Proc(int x, ref int ss, ref int cc)
        {
            ss = x * x;
            cc = x * x * x;
        } 
    } 
}

1. 0 0

2.25 25

3.125 125

4.25 125

Posted Date:-2021-02-24 10:36:42


Question:
Which of the following will be the correct output for the C#.NET program given below?  namespace IndiabixConsoleApplication {      class SampleProgram     {         static void Main(string[] args)         {              int num = 1;             funcv(num);              Console.Write(num + "", "");              funcr(ref num);              Console.Write(num + "", "");         }         static void funcv(int num)         {              num = num + 10; Console.Write(num + "", "");         }         static void funcr (ref int num)         {              num = num + 10; Console.Write(num + "", "");         }      }  }

1.1, 1, 1, 1,

2.11, 1, 11, 11,

3.11, 11, 11, 11,

4.11, 11, 21, 11,

Posted Date:-2021-02-24 10:36:42


More MCQS

  1. C# MCQS -Programming (.NET Framework)
  2. C# MCQS -Programming(Control Instructions)
  3. C# MCQS - Functions and Subroutines(.NET Framework)
  4. C# Programming-Constructors
  5. C# Programming- Arrays
  6. C# Programming -Structures
  7. C# Programming-Properties
  8. C# Programming -Exception Handling
  9. C# Programming -Interfaces
  10. C# Programming -Delegates
  11. C# Programming -Generics
  12. C# Programming - Datatypes
  13. C# Programming- Operators
  14. C# Programming -Classes and Objects
  15. NET Programming mcqs
  16. Computer Science Engineering (CSE) .NET Programming
  17. C# Programming Mcq Set 1
  18. C# Programming Mcq Set 2
  19. C#.NET Programming Mcq
Search
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!