PrepAway - Latest Free Exam Questions & Answers

What is the output of the following code: echo "1" + 2 * "0x02";

What is the output of the following code: echo “1” + 2 * “0x02”;

PrepAway - Latest Free Exam Questions & Answers

A.
1

B.
3

C.
5

D.
20

E.
7

6 Comments on “What is the output of the following code: echo "1" + 2 * "0x02";

  1. SM Farhad Hossain says:

    Answer: is { A. 1 }

    Description : first 2 * “0x02” // “0x02” is string because of double quotation

    2 * “0x02” = 0
    1+0 = 1




    1



    1
    1. Mia says:

      Could you please explain why 2 * “0x02” would return 0?
      Since “0x02” should be equal to the decimal value 2, this would run as 2 * 2 = 4.




      0



      0

Leave a Reply

Your email address will not be published. Required fields are marked *