98-372 · Question #51
You are creating an application using .NET Framework 4.0. You use the following code segment in the application. (Line numbers are given for reference only.) 01 string string1 = "hello"; 02 string…
The correct answer is A. True. The first comparison, at line 04, is true, as the values in both string1 and string2 are equal. In C#, the second comparison, at line 05, is false, as string is a reference type, and string1 and string2 are two different objects with different references. However, in Visual…
Question
You are creating an application using .NET Framework 4.0. You use the following code segment in the application. (Line numbers are given for reference only.) 01 string string1 = "hello"; 02 string string2 = "h"; 03 string2 += "ello"; 04 Console.WriteLine(string1 == string2); 05 Console.WriteLine((object)string1 == (object)string2); What is the output of the above code segment?
Exhibit
Options
- ATrue
- BFalse
- CFalse
- DTrue
How the community answered
(51 responses)- A71% (36)
- B8% (4)
- C18% (9)
- D4% (2)
Explanation
The first comparison, at line 04, is true, as the values in both string1 and string2 are equal. In C#, the second comparison, at line 05, is false, as string is a reference type, and string1 and string2 are two different objects with different references. However, in Visual Basic, the second comparison is true, as comparing the strings after converting them to Objects still compares the values in string1 and string2. The String object is an object that is used to manipulate strings. Strings have the values of words, numbers, and special characters, which are enclosed in single or double quotes. The String object contains many functions that are used to manipulate strings. String manipulation consists of joining strings, searching words and characters in a long string,
Topics
Community Discussion
No community discussion yet for this question.
