• nxdefiant@startrek.website
    link
    fedilink
    arrow-up
    7
    ·
    8 months ago

    It’s a shitty question. It’s implied by the fact that “24” is wrong that the answer is “6”, the length of the string “Monday”.

    In some languages dot access on objects could give you the properties of the object type (things pertaining to a “day” object) but this would still be ambiguous since a day’s length can be measured in many different ways.

    In others, it would require you to call length as a function (.length()) or not be available at all, or require you to pass the object into another function [ length_in_seconds(day_x)]

    • Matty_r@programming.dev
      link
      fedilink
      arrow-up
      12
      ·
      8 months ago

      I think the question is fine, but we have to assume they covered this type of method prior to the exam, where .length would result in the character count of a String.