About Question enthuware.ocpjp.v21.2.3699 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
n199a_
Posts: 8
Joined: Wed Jan 08, 2025 9:43 am
Contact:

About Question enthuware.ocpjp.v21.2.3699 :

Post by n199a_ »

Given:

Code: Select all

record Student(int id, String name) { }  
Which of the following methods will be added automatically to this record?

Code: Select all

public String getName(){ return name; }

Code: Select all

public setName(String name){ this.name = name; }

Code: Select all

public final boolean equals(Object)

Code: Select all

public final int hashCode() 

Code: Select all

public final String toString()
None of the answers are correct because the compiled code looks like this:

Code: Select all

public record Person(int id, String name) {
    public Person(int id, String name) {
        this.id = id;
        this.name = name;
    }

    public int id() {
        return this.id;
    }

    public String name() {
        return this.name;
    }
}

admin
Site Admin
Posts: 10385
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v21.2.3699 :

Post by admin »

Did you read the explanation? and how do you know the compiled class looks like what you have posted?

btw, record name is Student and you have posted code for Person.

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests