← Quiz: Records and Sealed Classes: all 10 questions
Quiz: Records and Sealed Classes · Question 2 of 10
What is the accessor method for the component marks in record Student(String name, int marks)?
What is the accessor method for the component marks in record Student(String name, int marks)?
- A.getMarks()
- B.marks()
- C.Student.marks
- D.getmarks()
Answer & explanation
Correct answer: marks()
Record accessors use the component name with no get prefix.
Can you get the rest right without peeking?
Take the timed Quiz: Records and Sealed Classes quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →