what is the output of "hello" +3?how the answer ...

Discussion in 'Web App and Programming' started by Jitendra Budiya, Oct 15, 2017.

  1. Jitendra Budiya

    Jitendra Budiya Customer
    Customer

    Joined:
    Oct 9, 2017
    Messages:
    2
    Likes Received:
    0
    what is the output of "hello" +3?

    how the answer is hello 3?

    how this is possible because we can't convert 'int' object to str implicitly
     
    #1
  2. Richard_62

    Richard_62 Well-Known Member
    Simplilearn Support

    Joined:
    Sep 9, 2016
    Messages:
    188
    Likes Received:
    33
    Jitendra,

    What script or coding is this written, Java, Javascript, Scala..........

    Different languages handle this differently.
    For instance, Javascript will automatically convert integers into strings when adding mixed variable types together while Java, and most higher level codes, will through an error and have to have the integer converted into a string first. "hello" + Integer.toString(number);

    Type casting of variables is important to maintain integrity of the software while in other cases not so much. Thus, different programming languages approach this differently.

    Thank you,
    Richard Kershner
     
    #2
  3. _18940

    _18940 Member

    Joined:
    Dec 25, 2017
    Messages:
    4
    Likes Received:
    0
    So you mean that the error will not come when we execute the command in bash script mode of python and will come up in interpreter mode?
     
    #3
  4. Priyanka_Mehta

    Priyanka_Mehta Well-Known Member
    Simplilearn Support

    Joined:
    May 25, 2017
    Messages:
    280
    Likes Received:
    18
    Yes Aditya, it will give you error in interpreter mode.
     
    #4

Share This Page