Oracle
1Z0-803 · Question #113
1Z0-803 Question #113: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-803 to reveal the answer and full explanation for question #113. The question stem and answer options stay visible for context.
Question
Given the code fragments: 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); } } Which code fragment, when inserted at line 13, enables class Test to print 123 : Fred : [Java, C] ?
Options
- Aprivate Student(int i, String name, List cs) {
- Bpublic void Student(int i, String name, List cs) {
- CStudent(int i, String name, List cs) {
- DStudent(int i, String name, ArrayList cs) {
Unlock 1Z0-803 to see the answer
You've previewed enough free 1Z0-803 questions. Unlock 1Z0-803 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.