About Question enthuware.ocpjp.v7.2.1736 :

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

Moderator: admin

Post Reply
rocky_bgta
Posts: 12
Joined: Thu Dec 11, 2014 12:32 am
Contact:

About Question enthuware.ocpjp.v7.2.1736 :

Post by rocky_bgta »

if I change the declaration as:

Code: Select all

int a = 10;
		Integer[] aa = { 10, 20 };
		long l = 30;

		probe(a);
		probe(aa);
		probe(l); 
it produce output as:
In Integer
In Integer..
In Long

but my question is why probe(aa) print: In Integer..
while it can also print: In Object
as

Code: Select all

int[]aa = {10, 20} 
declaration because

Code: Select all

Integer[]aa
"aa" is also object.

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

Re: About Question enthuware.ocpjp.v7.2.1736 :

Post by admin »

Because the parameter that matches more precisely is the one that is selected. aa does match Object but it matches more closely to Integer[].
You will read about it in explanations of other questions where this concept is tested.
HTH,
Paul.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest