206k views
0 votes
Given two Generic variables, A with value "123" and B with value 456, what would the Write Line output of A + B be? 123456 579 An exception will be thrown. 123 + 456

User Sahid
by
6.6k points

1 Answer

1 vote

Answer:

123456

Step-by-step explanation:

When an integer value is added to a string value the resulting value is a string.+ operator is used for both numeric additions and string addition also knows as string concatenation. In addition when one operand of the equation is a string the program interprets all values as string. As system is interpreting all values as a string it will apply a string addition method instead of mathematical addition.So here A is a string and B is an integer value. when we add A and B system will treat B aslo as a string, upon addition the result will be String concatenating both A and B to a single string.Hence the result of A+B will be

A+B = 123456

As WriteLine method takes string as Input it will just write the resulting string to file

User Jwillker
by
6.2k points