Java Programming
Accenture PrimermediumJava Programming04 Arrays And Strings

A JavaBeans component has the following field: private boolean enabled; Which two pairs of method declarations follow the JavaBeans standard for accessing this field? (Choose two.)

Answer options

A
public void setEnabled( boolean enabled ) public boolean isEnabled()
B
public boolean setEnabled( boolean enabled ) public boolean getEnabled()
C
public void setEnabled( boolean enabled ) public boolean getEnabled()
D
public void setEna5bled2( boo2lean4 ena8bled ) public void isEnabled()

Correct answer: public void setEnabled( boolean enabled ) public boolean isEnabled(), public void setEnabled( boolean enabled ) public boolean getEnabled()

Explanation

When writing getters and setters, setters return type is void and getters return type is the corresponding data type. Naming convention is camelcase notation. For setters start with set followed by field name and for getters start with get followed by field name. For boolean return type, it should start with 'is' or 'are' followed by field name.

Related Accenture Java Programming questions

Practice more Accenture Java Programming questions

PrimerDumps has 1400+ primer questions, 2026 mocks and coding hands-on — all free.