コードの断片を考えると、次のようになります。 9. class Student { 10. int rollnumber; 11. String name; 12. List courses = new ArrayList(); 13. // insert code fragment here 14. public String toString() { 15. return rollnumber + " : " + name + " : " + courses; 16. } 17. } And, public class Test { public static void main (String[] args) { List cs = new ArrayList(); cs.add("Java"); cs.add("C"); Student s = new Student(123,"Fred",cs); System.out.println(s); } } 13 行目に挿入すると、クラス Test が 123 : Fred : [Java, C] を出力できるようにするコード フラグメントはどれですか? private Student(int i, 文字列名, リスト cs) {
正解:C
Incorrect: Not A: Student has private access line: Student s = new Student(123,"Fred", cs); Not D: Cannot be applied to given types. Line: Student s = new Student(123,"Fred", cs);