My Report

C# Classes Test – 3


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. What will be the output of the following C# code?

  
static void Main(string[] args)
{
    Mul();
    m();
    Console.ReadLine();
}
static void Mul()
{
    Console.WriteLine("4");
}
static void m()
{
    Console.WriteLine("3");
    Mul();
}

2. What will be the output of the following C# code?

 public static void Main(string[] args)
 {
     p();
     void p()
     {
         Console.WriteLine("hi");
     }
 }

3. 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();
 }

4. Which of the following statements are correct about functions?

5. How many values does a function return?

6. 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?

7. 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();
 }

8. Which return statement correctly returns the output?

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

10. What will be the output of the following C# code?

 static void Main(string[] args)
 {
     int i = 10;
     double d = 35.78;
     fun(i);
     fun(d);
     Console.ReadLine();
 }
 static void fun(double d)
 {
     Console.WriteLine(d);
 }
 

 

Start practicing “1000 MCQs on C#”, and once you are ready, you can take tests on all topics by attempting our “C# Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.