What is the result?

Refer to the Exhibit.

01. public class A {
02. public String doit(int x, int y){
03. return “a”;
04. }
05.
06. public String doit(int… vals){
07. return “b”;
08. }
09. }

Given:

25. A a = new A();
26. System.out.println(a.doit(4, 5));

What is the result?

Refer to the Exhibit.

01. public class A {
02. public String doit(int x, int y){
03. return “a”;
04. }
05.
06. public String doit(int… vals){
07. return “b”;
08. }
09. }

Given:

25. A a = new A();
26. System.out.println(a.doit(4, 5));

What is the result?

A.
Line 26 prints a to System.out.

B.
Line 26 prints b to System.out.

C.
An exception is thrown at line 26 at runtime.

D.
Compilation of class A will fail due to an error in line 6.



Leave a Reply 1

Your email address will not be published. Required fields are marked *