OCA Java SE 8 Mock Exam Review - OCA Mock Question 6








Question

Given the following code, select the correct options:

package com.java2s.courses; 
public class Main { 
    public String courseName; 
    public void setCourseName(private String n) { 
        courseName = n; 
    } 
    public void setCourseName(int n) { 
    } 
    public static void main(){
    }
    public static void main(String a){
    }
    public static void main(String[] a){
    }
} 
  1. You can't define a method argument as a private variable.
  2. A method argument should be defined with either public or default accessibility.
  3. To override methods, method arguments should be defined with protected accessibility.
  4. None of the above.




Answer



A

Note

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