About Question enthuware.ocajp.i.v8.2.1460 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
enthunoob
Posts: 60
Joined: Thu Apr 15, 2021 12:21 pm
Contact:

About Question enthuware.ocajp.i.v8.2.1460 :

Post by enthunoob »

Code: Select all

public class ParamTest {
  public static void printSum(int a, Integer b){
      System.out.println("In int Integer "+(a+b));
  }
  
  public static void printSum(Integer a, Integer b){
      System.out.println("In Integer Integer "+(a+b));
  }
  
  public static void printSum(Integer a, int b){
      System.out.println("In Integer int "+(a+b));
  }
  
  public static void main(String[] args) {
      printSum(1, 2);
  }
}
When called with printSum(Integer.valueOf(1), 2) it works and prints In Integer in. But when this code runs, the JVM cant figure out what method to choose. Is that just the online compiler I'm using (https://www.programiz.com/java-programm ... -compiler/)?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1460 :

Post by admin »

Try it with regular Oracle jdk and see what happens. Also, please post exact code that you tried.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 32 guests