Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
nmims post
Objective Type Set
Online MCQ Assignment
Question Solution
Solved Question
Uncategorized

C# MCQ Set 1

1. The process of defining two or more methods within the same class that have same name but different parameters list?
a) Method overloading
b) Method overriding
c) Encapsulation
d) None of the mentioned

View Answer

Answer: a [Reason:] Two or more methods can have same name as long as their parameters declaration and definitions are different, the methods are said to be overloaded and the process is called method overloading. Method overloading is used when methods are required to perform similar tasks using different input parameters.

2. Which of these can be overloaded?
a) Constructors
b) Methods
c) Both Constructors & Methods
d) None of the mentioned

View Answer

Answer: c [Reason:] None.

3. What could be the output of the following set of code?

  1.  class Program
  2.  {
  3.      static void Main(string[] args)
  4.      {
  5.          Console.WriteLine( vol(10));
  6.          Console.WriteLine( vol(2.5f,  5));
  7.          Console.WriteLine( vol( 5l,  4,  5));
  8.          Console.ReadLine();
  9.      }
  10.      static int vol(int x)
  11.      {
  12.          return(x * x * x);
  13.      }
  14.      static float vol(float r,  int h)
  15.      {
  16.          return(3.14f * r * r * h);
  17.      }
  18.      static long vol(long l, int b, int h)
  19.      {
  20.          return(l * b * h);
  21.      }
  22.  }

a) 1000
0
100
b) 0
0
100
c) compile time error
d) 1000
98.125
100

View Answer

Answer: d [Reason:] The concept of method overloading is implemented in method “vol” with same name but different definitions and parameter list which is overloaded three times and each time the return type is different for each method and hence matches the method using types of parameters . Output: 1000 98.125 100

4. What could be the output for the set of code?

  1.   class overload
  2.   {
  3.       public int x;
  4.       int y;
  5.       public int add(int a)
  6.       {
  7.           x = a + 1;
  8.           return x;
  9.       }
  10.       public int add(int a, int b)
  11.       {
  12.           x = a + 2;
  13.           return x;
  14.       }
  15.   }    
  16.   class Program
  17.   {
  18.       static void Main(string[] args)
  19.       {
  20.           overload obj = new overload();
  21.           overload obj1 = new overload();
  22.           int a = 0;
  23.           obj.add(6);
  24.           obj1.add(6, 2);
  25.           Console.WriteLine(obj.x);
  26.           Console.WriteLine(obj1.x);
  27.           Console.ReadLine();
  28.       }
  29.   }

a) 8
8
b) 0
2
c) 8
10
d) 7
8

View Answer

Answer: d [Reason:] None. Output: 7, 8

5. What will be the output for the set of code?

  1.  static void Main(string[] args)
  2.  {
  3.      int i = 5;
  4.      int j  = 6;
  5.      add(ref i);
  6.      add(6);
  7.      Console.WriteLine(i);
  8.      Console.ReadLine();
  9.  }
  10.  static void add(ref int x)
  11.  {
  12.      x = x * x;
  13.  }
  14.  static void add(int x)
  15.  {
  16.      Console.WriteLine(x * x * x);
  17.  }

a) Compile time error
b) 25
0
c) 216
0
d) 216
25

View Answer

Answer: d [Reason:] None. Output: 216 25

6. What would be output for the set of code?

  1.  class maths
  2.  {
  3.      public int x;
  4.      public double y;
  5.      public int add(int a, int b)
  6.      {
  7.          x = a + b;
  8.          return x;
  9.      }
  10.      public int add(double c, double d)
  11.      {
  12.          y = c + d;
  13.          return (int)y;
  14.      }
  15.      public maths()
  16.      {
  17.          this.x = 0;
  18.          this.y = 0;
  19.      }
  20.  }    
  21. class Program
  22. {
  23.     static void Main(string[] args)
  24.     {
  25.         maths obj = new maths();
  26.         int a = 4;
  27.         double b = 3.5;
  28.         obj.add(a, a);
  29.         obj.add(b, b);
  30.         Console.WriteLine(obj.x + " " + obj.y);
  31.         Console.ReadLine();
  32.     }
  33. }

a) 4, 3.5
b) 8, 0
c) 7.5, 8
d) 8, 7

View Answer

Answer: d [Reason:] None Output: 8, 7

7. What will be output for the given set of code?

  1.  class maths
  2.  {
  3.      public static void fun1()
  4.      {
  5.          Console.WriteLine("method 1 :");
  6.      }
  7.      public void fun2()
  8.      {
  9.          fun1();
  10.          Console.WriteLine("method 2 :");
  11.      }
  12.      public void fun2(int k)
  13.      {
  14.          Console.WriteLine(k);
  15.          fun2();
  16.      }
  17.  }    
  18.  class Program
  19.  {
  20.      static void Main(string[] args)
  21.      {
  22.          maths obj = new maths();
  23.          maths.fun1();
  24.          obj.fun2(20);
  25.          Console.ReadLine();
  26.      }
  27.  }

a) method 1:
method 2:
20
method 1:
b) method 2:
20
method 1:
method 1:
c) method 1:
0
method 2:
method 2:
d) method 1:
20
method 1:
method 2:

View Answer

Answer: d [Reason:] None. Output : method 1: 20 method 1: method 2:

8. What is the process of defining a method in terms of itself, that is a method that calls itself?
a) Polymorphism
b) Abstraction
c) Encapsulation
d) Recursion

View Answer

Answer: d [Reason:] None.

9. What will be the output for the following set of code?

  1.  class maths
  2.  {
  3.      public int fun1(int k)
  4.      {
  5.          k = 20;
  6.          return k;
  7.      }
  8.      public Single fun1(float t)
  9.      {
  10.          t = 3.4f;
  11.          return t;
  12.      }
  13.  }  
  14.  class Program
  15.  {
  16.      static void Main(string[] args)
  17.      {
  18.          maths obj = new maths();
  19.          int i;
  20.          i = obj.fun1(30);
  21.          Console.WriteLine(i);
  22.          Single j;
  23.          j = obj.fun1(2.5f);
  24.          Console.WriteLine(j);
  25.          Console.ReadLine();
  26.      }
  27.  }

a) 30
2.5f
b) 2.5f
30
c) 20
2.5f
d) 20
3.4f

View Answer

Answer: d [Reason:] None. Output: 20 3.4f

10. What will be the output for the given set of code?

  1.  class maths
  2.  {
  3.      public int fun(int k, int y)
  4.      {
  5.          return k + y;
  6.      }
  7.      public int fun1(int t, float z)
  8.      {
  9.          return (t+(int)z);
  10.      }
  11.  }    
  12.  class Program
  13.  {
  14.      static void Main(string[] args)
  15.      {
  16.          maths obj = new maths();
  17.          int i;
  18.          int b = 90;
  19.          int c = 100;
  20.          int d = 12;
  21.          float l = 14.78f;
  22.          i = obj.fun(b, c);
  23.          Console.WriteLine(i);
  24.          int j = (obj.fun1(d,  l));
  25.          Console.WriteLine(j);
  26.          Console.ReadLine();
  27.      }
  28.  }

a) 190, 26.78f
b) 0, 26.78f
c) 190, 26
d) 190, 0

View Answer

Answer: c [Reason:] None. Output: 190 26

11. What will be the output for the set of code?

  1.  class maths
  2.  {
  3.      public int fun(int k, int y, int n)
  4.      {
  5.          Console.WriteLine(k + "  " + y + "  " + n);
  6.          return (k);
  7.      }
  8.      public int fun1(int t,float z)
  9.      {
  10.          Console.WriteLine(t + "  " + z);
  11.          return t;
  12.      }
  13.  }    
  14.  class Program
  15.  {
  16.      static void Main(string[] args)
  17.      {
  18.          maths obj = new maths();
  19.          int b = 90;
  20.          int c = 100;
  21.          int d ;
  22.          float l;
  23.          int i = obj.fun(b, c, 12);
  24.          int j = (obj.fun1(12, 14.78f));
  25.          Console.ReadLine();
  26.      }
  27.  }

a) 0, 0, 0
12, 14.78
b) 0, 0, 0
0, 0
c) 90, 100, 12
12, 14
d) 90, 100, 12
12, 14.78

View Answer

Answer: d [Reason:] None. Output: 90, 100, 12 12, 14.78

12. What will be the output for the given set of code?

  1.  class maths
  2.  {
  3.      public int fun(int ii)
  4.      {
  5.          return(ii > 0 ? ii :ii * -1);
  6.      }
  7.      public long fun(long ll)
  8.      {
  9.          return(ll > 0 ? ll :ll * -1);
  10.      }
  11.      public double fun( double dd)
  12.      {
  13.          return(dd > 0 ? dd :dd * -1);
  14.      }
  15.  }    
  16.  class Program
  17.  {
  18.      static void Main(string[] args)
  19.      {
  20.          maths obj = new maths();
  21.          int i = -25;
  22.          int j ;
  23.          long l = -100000l ;
  24.          long m;
  25.          double d = -12.34;
  26.          double e;
  27.          j = obj.fun(i);
  28.          m = obj.fun(l);
  29.          e = obj.fun(d);
  30.          Console.WriteLine(j + "  " + m + "  " + e);
  31.          Console.ReadLine();
  32.      }
  33.  }

a) 1 1 1
b) 0 0 0
c) 25 100000 12.34
d) -25 -100000 -12.34

View Answer

Answer: c [Reason:] None. Output: 25 100000 12.34

C# MCQ Set 2

1. Which keyword is used to declare a base class method while performing overidding of base class methods?
a) this
b) virtual
c) override
d) extend

View Answer

Answer: b [Reason:] None.

2. The process of defining a method in subclass having same name & type signature as a method in its superclass is known as?
a) Method overloading
b) Method overriding
c) Method hiding
d) None of the mentioned

View Answer

Answer: b [Reason:] None.

3. Which of the given modifiers can be used to prevent Method overriding?
a) Static
b) Constant
c) Sealed
d) final

View Answer

Answer: c [Reason:] When an instance method declaration includes sealed modifier,the method is said to be sealed method.It means a derived class cannot override this method.

4. Select the correct statement from the following?
a) Static methods can be a virtual method
b) Abstract methods can be a virtual method
c) When overriding a method, the names and type signatures of the override method must be the same as the virtual method that is being overriden
d) We can override virtual as well as non virtual methods

View Answer

Answer: c [Reason:] None.

5. Which of the following cannot be used to declare a class as a virtual?
a) Methods
b) Properties
c) Events
d) Fields

View Answer

Answer: d [Reason:] None.

6. What will be the output for the given set of code?

  1.  class A
  2.  {
  3.      public int i;
  4.      public void display() 
  5.      {
  6.          Console.WriteLine(i);
  7.      }
  8.  }    
  9.  class B: A 
  10.  {
  11.      public int j;
  12.      public void display() 
  13.      {
  14.          Console.WriteLine(j);
  15.      }
  16.  }    
  17.  class Program
  18.  {
  19.      static void Main(string[] args)
  20.      {
  21.          B obj = new B();
  22.          obj.i = 1;
  23.          obj.j = 2;
  24.          obj.display();
  25.          Console.ReadLine();
  26.      }
  27.  }

a) 0
b) 2
c) 1
d) Compile time error

View Answer

Answer: b [Reason:] When method display() is called using objects of class ‘B’. The method ‘display()’ for class ‘B’ is called instead of class ‘A’ as class ‘B’ is inherited by class ‘A’. Output :2

7. What will be the output for the given set of code?

  1.  class A 
  2.  {
  3.      public virtual void display() 
  4.      {
  5.          Console.WriteLine("A");
  6.      }    
  7.  }    
  8.  class B: A 
  9.  {
  10.     public override void display() 
  11.     {
  12.         Console.WriteLine(" B ");
  13.     } 
  14.  }    
  15. class Program
  16. {
  17.     static void Main(string[] args)
  18.     {
  19.         A obj1 = new A();
  20.         B obj2 = new B();
  21.         A r;
  22.         r = obj1;
  23.         r.display();
  24.         r = obj2;
  25.         r.display();     
  26.         Console.ReadLine();
  27.     }
  28. }

a) A, A
b) B, B
c) Compile time error
d) A, B

View Answer

Answer: d [Reason:] The method overidding procedure has been used to produce the values from two display(). Output : A B

8. The modifier used to hide the base class methods is ?
a) Virtual
b) New
c) Override
d) Sealed

View Answer

Answer: b [Reason:] Used in condition when we cannot use virtual to override a base class method. Hence, we use ‘New’ to hide the base class methods and redefine the method defined in sub class.

9. To override a method in subclass, baseclass method should be defined as?
a) Virtual
b) Abstract
c) Override
d) All of the mentioned.

View Answer

Answer: d [Reason:] None.

10. What will be the output for the given set of code?

  1.  class a
  2.  {
  3.      public  void fun()
  4.      {
  5.          Console.WriteLine("base method");
  6.      }
  7.  }
  8.  class b: a
  9.  {
  10.      public new void fun()
  11.      {
  12.          Console.WriteLine(" derived method ");
  13.      }
  14.  }
  15.  class Program
  16.  {
  17.      static void Main(string[] args)
  18.      {
  19.          b k = new b();
  20.          k.fun();
  21.          Console.ReadLine();
  22.      }
  23.  }

a) Base method
b) Derived method
c) Code runs successfully prints nothing
d) Compile time error

View Answer

Answer: b [Reason:] Use of ‘new’ modifier hides the inherited member i.e it makes only inherited member inaccessible in derived class and hence calls suitable method(). Output :derived method

C# MCQ Set 3

1. What is the output of the following set of code?

  1.  static void Main(string[] args)
  2.  {
  3.      int a = 5;
  4.      int s = 0, c = 0;
  5.      Mul (a, ref s, ref c);
  6.      Console.WriteLine(s + "t " +c);
  7.      Console.ReadLine();
  8.  }
  9.  static void Mul (int x, ref int ss, ref int cc)
  10.  {
  11.      ss = x * x;
  12.      cc = x * x * x;
  13.  }

a) 125 25
b) 25 125
c) Compile time error
d) 0 0

View Answer

Answer: b [Reason:] The value of variable a is passed by value while value of variable s and c is passed by reference. Output: 25 125.

2. Which of following statements are correct about functions?
a) C# allows a function to have arguments with default values
b) Redefining a method parameter in the method’s body causes an exception
c) C# allows function to have arguments with default values
d) Omitting the return type in method definition results into exception

View Answer

Answer: a [Reason:] None.

3. What is output of the code?

  1. static void Main(string[] args)
  2. {
  3.     Mul();
  4.     m();
  5.     Console.ReadLine();
  6. }
  7. static void Mul()
  8. {
  9.     Console.WriteLine("4");
  10. }
  11. static void m()
  12. {
  13.     Console.WriteLine("3");
  14.     Mul();
  15. }

a) 4 3 3
b) 4 4 3
c) 4 3 4
d) 3 4 4

View Answer

Answer: c [Reason:] First Mul() will be executed to print the number ‘4’ after that function m() will be executed to print the number ‘3’ and at last mentioned function Mul() will be executed to print the statement 4 to return the output as 4 3 4. Output: 4 3 4.

4. What is the output of the code ?

  1.  static void Main(string[] args)
  2.  {
  3.      m();
  4.      Console.ReadLine();
  5.  }
  6.  static void m()
  7.  {
  8.      Console.WriteLine("HI");
  9.      m();
  10.  }

a) HI HI HI
b) HI
c) Stack overflow exception
d) Compile time error

View Answer

Answer: c [Reason:] Control of statement when enters for once in m() does not go out, then it executes again and again inside the block until stack overflow exception occurs.

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 function is?

a) static fun(int i, single j, double k)
   {
       return decimal;
   }
b) static decimal fun(int i, single, double k)
   {
 
   }
c) decimal fun(int i, single j, double k)
   {
 
   }
d) decimal static fun(int i, single j, double k)
   {
 
   }

View Answer

Answer: b [Reason:] Correct way of declaration of function is defined as return_type name of function(returntype).

6. What is the output for the following set of code :

  1.  static void Main(string[] args)
  2.  {
  3.      int i = 10;
  4.      double d = 35.78;
  5.      fun(i);
  6.      fun(d);
  7.      Console.ReadLine();
  8.  }
  9.  static void fun(double d)
  10.  {
  11.      Console.WriteLine(d);
  12.  }

a) 35.78
10
b) 10
35.00
c) 10
35.78
d) None of the mentioned

View Answer

Answer: c [Reason:] ‘int’ datatype is sub datatype of ‘double’.Hence, when first part of func() is executed it is integer part and hence when second part is executed it is double. Output:10 35.78

7. How many values does a function return?
a) 0
b) 2
c) 1
d) any number of values

View Answer

Answer: c [Reason:] A method can return only either single value or no value if no then it’s declared as void method();

8. Output for the following set of code :

  1.  static void Main(string[] args)
  2.  {
  3.      int y = 3;
  4.      y++;
  5.      if (y <= 5)
  6.      { 
  7.          Console.WriteLine("hi");
  8.          Main(args);
  9.      }
  10.      Console.ReadLine();
  11.  }

a) hi hi
b) hi
c) Stack overflow exception
d) None of the mentioned

View Answer

Answer: c [Reason:] If loop never gets over, it will execute continuously.The control never goes out of ‘if’ statement. Output: hi hi . . . stack overflow exception

9. Which return statement correctly returns the output:
a) public int cube(int x)
{
return (x + x);
}
b) public int cube(int x)
return (x + x);
c) public int cube(int x)
{
return x + x;
}
d) None of mentioned

View Answer

Answer: a [Reason:] The correct syntax of return statement is defined within block of statements as { return(statement);}.

10. What is the output for selective code ?

  1.  public static void Main(string[] args)
  2.  {
  3.      p();
  4.      void p()
  5.      {
  6.          Console.WriteLine("hi");
  7.      }
  8.  }

a) Compile time error
b) hi
c) hi infinite times
d) None of the mentioned

View Answer

Answer: a [Reason:] invalid definition of function p() inside main().

C# MCQ Set 4

1. Which of these methods of the class String is used to obtain length of String object?
a) get()
b) Sizeof()
c) lengthof()
d) length()

View Answer

Answer: d [Reason:] Method length() of string class is used to get the length of the object as string.Length and hence invokes the length() method.

2. Which of these methods is an alternative to getChars() that stores the characters in an array of bytes?
a) getBytes()
b) GetByte()
c) giveByte()
d) Give Bytes()

View Answer

Answer: a [Reason:] getBytes() stores the character in an array of bytes. It uses default character to byte conversions.

3. Which of these methods can be used to convert all characters in a String into a character array?
a) CharAt()
b) getChars()
c) TocharArray()
d) All of the mentioned

View Answer

Answer: c [Reason:] None.

4. What will be the output of the given code snippet?

  1.  static void main(String args[])
  2.  {
  3.      char chars[] = {'x', 'y', 'z'};
  4.      String s = new String(chars);
  5.      Console.WriteLine(s);
  6.  }

a) x
b) xy
c) z
d) xyz

View Answer

Answer: d [Reason:] String(chars) is a constructor of class string, it initializes string s with the values stored in character array chars, therefore s contains “xyz”. Output :xyz

5. Choose the effective stringBuilder method which helps in producing output for the given code?

  1.  static void Main(string[] args)
  2.  {
  3.      StringBuilder s = new StringBuilder("object");
  4.      s./*______*/("Oriented Language");
  5.      Console.WriteLine(s);
  6.      Console.ReadLine();
  7.  }
  8. Output : objectOriented Language

a) Insert()
b) Add()
c) Append()
d) Join()

View Answer

Answer: c [Reason:] static void Main(string[] args) { StringBuilder s = new StringBuilder(“object”); s.Append(“Oriented Language”); Console.WriteLine(s); Console.ReadLine(); } Output : objectOriented Language

6. What will be the output for the given code snippet?

  1.   static void Main(string[] args)
  2.   {
  3.       string s = " i love you";
  4.       Console.WriteLine(s.IndexOf('l') + "  " + s.lastIndexOf('o') + "  " + s.IndexOf('e'));
  5.       Console.ReadLine();
  6.   }

a) 3 5 7
b) 4 5 6
c) 3 9 6
d) 2 4 6

View Answer

Answer: c [Reason:] indexof(‘l’) and lastIndexof(‘o’) are pre defined functions which are used to get the index of first and last occurrence of the character pointed by l and c respectively in the given array. Output : 3, 9, 6

7. Which of these methods of class String is used to extract all the characters from a String object?
a) CHARAT()
b) Remove()
c) charAt()
d) Replace()

View Answer

Answer: b [Reason:] Replace() replaces all instances of a character with a new character while Remove extracts characters from the string.

8. What will be the output of the given code snippet?

  1.  static void Main(string[] args)
  2.  {
  3.      string c = "hello";
  4.      string  c1 = c.Remove(1);
  5.      Console.WriteLine(c1);
  6.      Console.ReadLine();
  7.  }

a) ello
b) h
c) hell
d) none of the mentioned

View Answer

Answer: b [Reason:] The remove() deletes characters from the string except the character which is specified with its given position. Output : h

9. How is a string typically processed?
a) On a character by character basis
b) On a string by string basis
c) Both a & b
d) None of the mentioned

View Answer

Answer: a [Reason:] None.

10. How to print on the screen?
a) Console.WriteLine(“”);
b) Console.WriteLine(“”);
c) Console.WriteLine(“\”);
d) Console.WriteLine(“\”);

View Answer

Answer: c [Reason:] Console.WriteLine(“\”); Output :

C# MCQ Set 5

1. Which of the following string() method are used to compare two strings with each other?
a) CopyTo()
b) Copy()
c) Compare()
d) CompareTo()

View Answer

Answer: b [Reason:] Creates a new string by copying one string to another.

2. Choose the base class for string() method :
a) System.Array
b) System.char
c) System.String
d) None of the mentioned

View Answer

Answer: c [Reason:] String is an alias for the predefined “System.string” class from which most of the string() methods are derived.

3. What is output for the following set of code:

  1.  static void Main(string[] args)
  2.  {
  3.      string s1 = " Cshr ";
  4.      string s2 = s1.Insert(3 , " a ");
  5.      string s3 = s2.Insert(5 , " p ");
  6.      for (int i = 0;i < s3.Length; i++)
  7.      Console.WriteLine(s3[i]);
  8.      Console.ReadLine();
  9.  }

a) Cshar
b) CsharP
c) Csharp
d) Cshrap

View Answer

Answer: c [Reason:] Insertion of character ‘a’ at postion ‘3’ using insert() which returns a new string with a substring inserted at a specified location. Output: Csharp

4. Which of the following statement is correct about a string in C#.NET?
a) The System.Array class is used to represent a string
b) A string has a zero-based index
c) A number cannot be represented in the form of a string
d) A string is mutable because it can be modified once it has been created

View Answer

Answer: b [Reason:] None.

5. What is output for the following set of code?

  1.  static void Main(string[] args)
  2.  {
  3.      string s1 = "Hello";
  4.      string s2 = "hello";
  5.      if (s1 == s2)
  6.      Console.WriteLine("Equal");
  7.      else
  8.      Console.WriteLine("Unequal");
  9.      if (s1.Equals (s2))
  10.      Console.WriteLine("Equal");
  11.      else
  12.      Console.WriteLine("Unequal");
  13.      Console.ReadLine();
  14.  }

a) Equal
Unequal
b) Unequal
Equal
c) Equal
Equal
d) Unequal
Unequal

View Answer

Answer: d [Reason:] In first comparison it is being checked either two strings are equal or not but in second comparison it is checked whether two references are equal or not. Output: Unequal Unequal

6. Choose Output for the following set of code :

  1. static void Main(string[] args)
  2. {
  3.     string s1 = "Hello" + " I " + "Love" + " ComputerScience ";
  4.     Console.WriteLine(s1);
  5.     Console.ReadLine();
  6. }

a) HelloILoveComputerScience
b) Hello I Love ComputerScience
c) Compile time error
d) Hello

View Answer

Answer: b [Reason:] Here ‘+’ defined operator works as concatenation for strings. Output : Hello I Love ComputerScience.

7. Correct way to find if contents of two strings are equal ?
a) if (s1 = s2)
b) if (s1 != s2)
c) if (strcmp (s1 ,s2))
d) if ( s1 is s2)

View Answer

Answer: c [Reason:] “==” operator used to compare length of two strings and strcmp() is the inbuilt method derived from string class.

8. Which of the following statements are correct?
a) String is value type
b) String literals can contain any character literal including escape sequences
c) The equality operators are defined to compare values of string objects as well as references
d) All of the mentioned

View Answer

Answer: b [Reason:] None

9. Which of these operators can be used to concatenate two or more String objects?
a) +
b) +=
c) &
d) ||

View Answer

Answer: a [Reason:] string s1 = “Hello”+ ” I ” + “Love” + ” ComputerScience “; Console.WriteLine(s1); Hello I Love ComputerScience.

10. The Method use to remove white space from string?
a) Split()
b) Substring()
c) Trim()
d) TrimStart()

View Answer

Answer: c [Reason:] Perfectly removes a whitespace from string whereas TrimStart() removes a string of characters from the end of the string.

.woocommerce-message { background-color: #98C391 !important; }