gs gs108 Classes - Methods in Class - Quiz No.1
gs gs108 CSharp Quiz
This quiz belongs to book/course code gs gs108 CSharp of gs organization. We have 110 quizzes available related to the book/course CSharp. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Classes. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
Question 1: What will be the output of the following C# code?
static void Main(string[] args) { int a = 5; int s = 0, c = 0; Mul (a, ref s, ref c); Console.WriteLine(s + "t " +c); Console.ReadLine(); } static void Mul (int x, ref int ss, ref int cc) { ss = x * x; cc = x * x * x; }
125 25
25 125
Compile time error
0 0
Question 2: Which of the following statements are correct about functions?
C# allows a function to have arguments with default values
Redefining a method parameter in the method’s body causes an exception
C# allows function to have arguments with default values
Omitting the return type in method definition results into exception
Question 4: What will be the output of the following C# code?
static void Main(string[] args) { m(); Console.ReadLine(); } static void m() { Console.WriteLine("HI"); m(); }
HI HI HI
HI
Stack overflow exception
Compile time error
Question 5: When a function fun() is to receive an int, a single & a double and it is to return a decimal, then the correct way of defining this C# function is?
static fun(int i, single j, double k) { return decimal; }
static decimal fun(int i, single, double k) { }
decimal fun(int i, single j, double k) { }
decimal static fun(int i, single j, double k) { }
Question 7: How many values does a function return?
0
2
1
any number of values
Question 8: What will be the output of the following C# code?
static void Main(string[] args) { int y = 3; y++; if (y <= 5) { Console.WriteLine("hi"); Main(args); } Console.ReadLine(); }
hi hi
hi
Stack overflow exception
None of the mentioned
Question 9: Which return statement correctly returns the output?
public int cube(int x) { return (x + x); }
public int cube(int x) return (x + x);
public int cube(int x) { return x + x; }
None of the mentioned
Question 10: What will be the output of the following C# code?
public static void Main(string[] args) { p(); void p() { Console.WriteLine("hi"); } }
Compile time error
hi
hi infinite times
None of the mentioned