Type Conversion Quiz

  int = 5
  float = 5.5
  string = "5"

  puts int + float # ...... A
  puts string + int # ..... B
  puts string + string # .. C
  puts float + string # ... D

Which of the above expressions will throw an error?

A B C D
  int = 5
  float = 5.5
  string = "5"

  puts int * float # ...... A
  puts string * int # ..... B
  puts string * string # .. C
  puts float * string # ... D

Which of the above expressions will throw an error?

A B C D
  puts 5.to_s.to_i.to_f.to_s

What is the result of the above expression?

5 5.0 "5" "5.0"

results matching ""

    No results matching ""