🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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)?

  1. A.getMarks()
  2. B.marks()
  3. C.Student.marks
  4. 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 →