多选题 A method needs to be created that accepts an array of floats as an argument and does not return any variables. The method should be called setPoints. Which of the following method declarations is correct?
  • A. setPoints(float[] points) {...}
  • B. void setPoints(float points) {...}
  • C. void setPoints(float[] points) {...}
  • D. float setPoints(float[] points) {...}
【正确答案】 C
【答案解析】void必须用于不返回任何数据的方法。A、B和D不正确。A不正确,因为它缺少返回类型。如果方法不打算返回一个变量,它仍然要使用void。B不正确,因为它没有float数组作为参数。D不正确,因为它使用了错误的返回类型。