About Question enthuware.ocpjp.v7.2.1306 :

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

Moderator: admin

Post Reply
jagoneye
Posts: 97
Joined: Wed Dec 28, 2016 9:00 am
Contact:

About Question enthuware.ocpjp.v7.2.1306 :

Post by jagoneye »

Can you please explain to me what is the purpose of this method??

Code: Select all

binarySearch(T[] a, T key, Comparator<? super T> c)
Why do you need to provide a Comparator when the requirement to search is that
you need the array or the list to be sorted first and you can use the Comparator
during sorting. So i don't understand the practical use of this method.
Another question is that in case of this question, if I pass anything other than String in binarysearch say

Code: Select all

Arrays.binarySearch(sa, 5)
it compiles without any errors whereas if the same array was of primitive type it
doesn't compile if I pass other than the primitive type. I'm guessing it has something to do with strongly typed primitive arrays while String not being a data type.

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

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

Post by admin »

1. How will you compare the object that you are searching for with the objects in the array?
2. The call in being bound to another binarySearch method binarySearch(Object[] a, Object key)
If you like our products and services, please help us by posting your review here.

waraging
Posts: 2
Joined: Sun Mar 21, 2021 12:27 pm
Contact:

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

Post by waraging »

why is the question giving a very ambiguous with the word (independent of each other or together) that make people read that it should be separate answer

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

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

Post by admin »

It just means that you could either use each option independently or use them together to achieve the desired output.
If you like our products and services, please help us by posting your review here.

asi-aal
Posts: 10
Joined: Wed Nov 23, 2022 3:40 am
Contact:

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

Post by asi-aal »

waraging wrote:
Fri Apr 02, 2021 2:59 am
why is the question giving a very ambiguous with the word (independent of each other or together) that make people read that it should be separate answer
I agree, for me it sounded the same

Post Reply

Who is online

Users browsing this forum: No registered users and 44 guests