オブジェクト指向の基礎計算問題

次のコードを実行したとき、出力結果として正しいものはどれですか? class Student { private int score1; private int score2; private int score3; Student(int s1, int s2, int s3) { this.score1 = s1; this.score2 = s2; this.score3 = s3; } double getAverage() { return (score1 + score2 + score3) / 3.0; } } public class Main { public static void main(String[] args) { Student student = new Student(80, 90, 70); System.out.println(student.getAverage()); } }

A.80.0← 正解
✓ 正解です。(80 + 90 + 70) / 3.0 = 240 / 3.0 = 80.0が平均点となります。
B.85.0
✗ 最高得点90と最低得点70の平均値です。全3つの成績の平均ではありません。
C.240.0
✗ 3つの得点の合計です。平均値はこれを3で割った値です。
D.80
✗ 整数で返却されています。このメソッドはdouble型で80.0を返却します。

Oracle Certified Java Programmer, Bronze SE の問題一覧