Java OCA OCP Practice Question 2365

Question

Given the following code, select the correct options:

package com.mypkg.courses; 
class Course { 
    public String courseName; 
    public void setCourseName(private String name) { 
        courseName = name; 
    } 
} 
  • a You can't define a method argument as a private variable.
  • b A method argument should be defined with either public or default accessibility.
  • c For overridden methods, method arguments should be defined with protected accessibility.
  • d None of the above.


a

Note

You can't add an explicit accessibility keyword to the method parameters.

If you do, the code won't compile.




PreviousNext

Related