My Report

C# Programming Practice 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. Which of these methods returns the string such that some characters which are specified to be removed from the end of strings are removed from string by mentioning the number of characters to be removed?

2. Select wrong statement about destructor in C#?

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

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

       
   static void Main(string[] args)
   {
       int x = 8;
       int b = 16;
       int C = 64;
       x /= b /= C /= x;
       Console.WriteLine(x + " " + b+ " " +C);
       Console.ReadLine();
   }
  

5. Which of the following statements are correct?

6. The correct way of defining constructor of the given class as and when objects of classes are created is:

   maths s1 = new maths();
   maths s2 = new maths(5, 5.4f);

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

  static void Main(string[] args)
  {
      String a = "Ilove";
      String b = "CSHARP";
      b = string.Concat(a,' ',b);
      string d = b.TrimStart('I', 'l', 'o', 'H');
      Console.WriteLine(d);
      Console.ReadLine();
  }

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

  static void Main(string[] args)
  {
      int a = 10 , b = 20;
      Console.WriteLine("Result before swap is: "+ a +" "+b);
      swap(ref a, ref b);
      Console.ReadLine();
  }
  static void swap(ref int i, ref int j)
  {
      int t;
      t = i;
      i = j;
      j = t;
      Console.WriteLine("Result after swap is:"+ i +" "+j);
  }
 

9. Which of these methods of class String is used to separate a substring from a String object?

10. Choose the base class for string() method:


 

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.