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








Question

Given the following signature of method print, choose the correctly overloaded method in the options:

public String print(int age, String name, double duration) 

a  private String print(int val, String firstName, double dur) 
b  public void print(int val1, String val2, double val3) 
c  String print(String name, int age, double duration) 
d  float print(double name, String age, byte duration) 
e  List<String> print() 
f  char[] print(double numbers) 
g  void print() 




Answer



c, d, e, f, g

Note

A is incorrect. Overloaded methods can change the access modifiers, but changing the access modifier and parameter name won't make it an overloaded method.

B is incorrect. Overloaded methods can change the return type of the method, but changing the return type won't make it an overloaded method.

C is correct. Changing the sequence of the types of the method parameters overloads it.

D is correct. Changing the return type of a method and the placement of the types of the method parameters overloads it.

E is correct. Changing the return type of a method and making a change in the parameter list overload it.

F is correct. Changing the return type of a method and making a change in the parameter list overload it.

G is correct. Changing the parameter list overloads a method.