Which line of code produces an error?
a. “one” + ‘two’
b. 1+2
c. “one” + “2”
d. ‘1’ + 2
Answers
Answered by
5
Answer:
I think (c)
if wrong then sorry
Answered by
2
d. '1' + 2 is the correct option.
In any programming language, there is a concept of datatypes that is the true definition of a variable defined by the user.
- In the first and third options, both are of string datatype which can be operated.
- In the second option, both are of integer datatype that too can be operated.
- But in the fourth option, one of it is of string and the other is of integer data type. It is an improper data type conversion to be operated on. So, it will give an error on execution of "unsupported operand type".
Similar questions