About Question enthuware.ocpjp.v7.2.1280 :

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

Moderator: admin

Post Reply
shareef.hiasat
Posts: 20
Joined: Thu Dec 19, 2013 8:22 am
Contact:

About Question enthuware.ocpjp.v7.2.1280 :

Post by shareef.hiasat »

This cant convince me i think the ceiling and higher is the same ,,.. or what

aaa --> higher b as question
so isnt
aaa --> ceiling b too but in the question its not

why

bb --> higher c as question
so isnt
bb -->ceiling is c too ?

E ceiling(E e)
Returns the least element in this set greater than or equal to the given element, or null if there is no such element.
E floor(E e)
Returns the greatest element in this set less than or equal to the given element, or null if there is no such element.
E higher(E e)
Returns the least element in this set strictly greater than the given element, or null if there is no such element.
E lower(E e)
Returns the greatest element in this set strictly less than the given element, or null if there is no such element.


Note that methods of NavigableMap (such as ceilingEntry(), ceilingKey(), floorEntry(), floorKey() etc.) also work exactly the same way.

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

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

Post by admin »

ceiling and higher are not same. Kindly read their descriptions. In some cases, they may return same values but not in all.
System.out.println(ns.higher("bb")); //prints c
System.out.println(ns.ceiling("bb")); //prints bb

shareef.hiasat
Posts: 20
Joined: Thu Dec 19, 2013 8:22 am
Contact:

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

Post by shareef.hiasat »

admin wrote:ceiling and higher are not same. Kindly read their descriptions. In some cases, they may return same values but not in all.
System.out.println(ns.higher("bb")); //prints c
System.out.println(ns.ceiling("bb")); //prints bb
ok but what is the rule here in this example please

Image
Image
http://s14.postimg.org/6t1xswti9/cielling.jpg

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

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

Post by admin »

I am sorry I didn't understand your question. Rule is same for this question. Higher and ceiling are different methods and work differently.

Svetopolk
Posts: 22
Joined: Sun Nov 18, 2012 1:51 am
Contact:

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

Post by Svetopolk »

"Returns the least element in this set greater than ... " - the explanation is formally correct but from the other hand it seems it is made to confuse.

I offer followed just to easy remembering:

higher - higher (greater)
ceiling - higher or equal

lower - lower (smaller)
floor - lower or equal

dmullandev2
Posts: 2
Joined: Fri Apr 28, 2023 6:45 am
Contact:

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

Post by dmullandev2 »

NavigableSet<String> myStringSet = new TreeSet<String>();
myStringSet.add("a");
myStringSet.add("aa");
myStringSet.add("b");
myStringSet.add("bb");
myStringSet.add("c");
myStringSet.add("cc");
System.out.println();
System.out.println(myStringSet);
System.out.println("TreeSet.ceiling(): " + myStringSet.ceiling("a"));
System.out.println("TreeSet.higher(): " + myStringSet.higher("a"));

Output:
[a, aa, b, bb, c, cc]
TreeSet.ceiling(): a
TreeSet.higher(): aa

doesn't seem right to me? how is aa higher than higher("a")?

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

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

Post by admin »

>>how is aa higher than higher("a")?

Not sure what you mean. Can you please clarify your question?

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests