functions and subroutines questions

6.

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;
}
}
}

A.     0 0
B.     25 25
C.     125 125
D.     25 125
E.     None of the above
Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
7.

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 + ” “);
}
}
}

A.     10.000000 34.340000
B.     10 34
C.     10 34.340
D.     10 34.34
Answer & Explanation

Answer: Option D

Explanation:

No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
8.

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.

A.     1, 3, 5
B.     3, 4, 5
C.     2, 5
D.     4, 5
E.     None of these
Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
9.

If a procedure fun() is to receive an int, a Single & a double and it is to return a decimal then which of the following is the correct way of defining this procedure?
A.

fun(int i, Single j, double k) decimal
{ … }

B.

static decimal fun(int i, Single j, double k)
{ … }

C.

fun(int i, Single j, double k)
{

return decimal;
}

D.

static decimal fun(int i, Single j, double k) decimal
{ … }

E.     A procedure can never return a value.
Answer & Explanation

Answer: Option E

Explanation:

No answer description available for this question. Let us discuss.
View Answer Workspace Report Discuss in Forum
10.

If a function fun() is to receive an int, a Single & a double and it is to return a decimal then which of the following is the correct way of defining this function?
A.

decimal static fun(int i, Single j, double k)
{ … }

B.

decimal fun(int i, Single j, double k)
{ … }

C.

static decimal fun(int i, Single j, double k)
{ … }

D.

static decimal fun(int i, Single j, double k) decimal
{ … }

E.

static fun(int i, Single j, double k)
{

return decimal;
}

Answer & Explanation

Answer: Option C

Explanation:

No answer description available for this question.

Leave a Reply0

Your email address will not be published.