Java OCA OCP Practice Question 1162

Question

Which of the following is a valid JavaBean method signature?

A.   public void getValue() 
B.   public void setBow() 
C.   public void setValue(int range) 
D.   public String addValue(String target) 


C.

Note

Option A is incorrect because the getter should return a value.

Option B is incorrect because the setter should take a value.

Option D is incorrect because the setter should start with set and should not return a value.

Option C is a correct setter declaration because it takes a value, uses the void return type, and uses the correct naming convention.




PreviousNext

Related