My Report

C# Programming Mock 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
 10%

Question 1 of 10

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

 class Program
 {
     static void Main(string[] args)
     { 
         String c = "i love Csharp";
         bool a;
         a = c.StartsWith("I");
         Console.WriteLine(a);
         Console.ReadLine();
     }
 }

Question 1 of 10

Question 2 of 10

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

 static void Main(string[] args)
 {
     String c = "Hello";
     String a = c + "Bye";
     Console.WriteLine(a);
     Console.ReadLine();
 }

Question 2 of 10

Question 3 of 10

3. Which of these methods of class are used to remove the leading and backward whitespaces?

Question 3 of 10

Question 4 of 10

4. Which return statement correctly returns the output?

Question 4 of 10

Question 5 of 10

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

static void Main(string[] args)
{
    Program p = new Program();
    p.display(2, 3, 8);
    int []a = { 2, 56, 78, 66 };
    Console.WriteLine("example of array");
    Console.WriteLine("elements added are");
    p.display(a);
    Console.ReadLine();
}
public void display(params int[] b)
{
    foreach (int i in b)
    {
        Console.WriteLine("ARRAY IS HAVING:{0}", i);
    }
}

Question 5 of 10

Question 6 of 10

6. Which of the following statements are correct?

Question 6 of 10

Question 7 of 10

7. Which method has the same name as that of its class?

Question 7 of 10

Question 8 of 10

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

 
 static void Main(string[] args)
 {
     string s1 = "Hello I Love Csharp ";
     Console.WriteLine(Convert.ToChar( (s1.IndexOf('I') - s1.IndexOf('l')) * s1.IndexOf('p'));
     Console.ReadLine();
 }

Question 8 of 10

Question 9 of 10

9. Which is the correct way of defining and initializing an array of 3 integers?

Question 9 of 10

Question 10 of 10

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

Question 10 of 10


 

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.