C# multiple choice questions on comparison of two strings in C# Programming Language. 1. Which of these methods of class String is used to compare two String objects for their equality? 2. Which of these methods is used to compare two strings such that after comparison output returns different integer values as (0 for false, 1 for true)? 3. Which of these methods of class String is used to check whether a substring exists at the beginning of the particular string? 4. 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? 5. What is the value returned by function compareTo() if the invoking string is less than the string compared? 6. Which of these data type values is returned by equals() method of String class? 7. What will be the output of the following C# code?
a) true 8. What will be the output of the following C# code?
a) true true 9. What will be the output of the following C# code?
a) zx 10. What will be the output of the following C# code?
a) 0 What is the value returned by function compareTo () If the invoking string is greater than the string compared *?4. What is the value returned by function compareTo() if the invoking string is greater than the string compared? Explanation: if (s1 == s2) then 0, if(s1 > s2) > 0, if (s1 < s2) then < 0.
What is the return type of string compareTo () method?The Java String class compareTo() method compares the given string with the current string lexicographically. It returns a positive number, negative number, or 0. It compares strings on the basis of the Unicode value of each character in the strings.
Which data type value is returned by equals () method of string class?Which of these data type values is returned by equals() method of String class? Explanation: equals() method of string class returns boolean value true if both the strings are equal and false if they are unequal.
Which of these method of class string is used to compare two string objects for their equality equals () equals () Isequal () Isequal ()?3) By Using compareTo() method
The String class compareTo() method compares values lexicographically and returns an integer value that describes if first string is less than, equal to or greater than second string. Suppose s1 and s2 are two String objects. If: s1 == s2 : The method returns 0.
|