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
Correct answer: public void setEnabled( boolean enabled ) public boolean getEnabled(), public void setEnabled( boolean enabled ) public boolean isEnabled()
Explanation
Quick AnswerThe correct answer is public void setEnabled( boolean enabled ) public boolean getEnabled(), public void setEnabled( boolean enabled ) public boolean isEnabled() because it directly addresses the core logic of Java Programming.
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.