Home / CSE MCQs / C#.Net MCQs :: Discussion

Discussion :: C#.Net MCQs

  1. What would be the output for the following set of code?

    static void Main(string[] args)
     {
         String obj = "hello";
         String obj1 = "world";   
         String obj2 = obj;
         Console.WriteLine (obj.Equals(obj2) + "  " + obj2.CompareTo(obj) );
         Console.ReadLine();
     }
  2. A.
    True True
    B.
    False False
    C.
    True 0
    D.
    False 1

    View Answer

    Workspace

    Answer : Option C

    Explanation :

    Equal() checks if two string objects 'obj' and 'obj2' are equal or not and hence returns true or false.Similarly, "CompareTo operator check two objects and since string obj2 = obj,it returns bool value '0'. Hence,they are equal. Output : True 0


Be The First To Comment