Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Liutauras Vilda
Paul Clapham
Sheriffs:
paul wheaton
Tim Cooke
Henry Wong
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Piet Souris
Bartenders:
Mike London
Forum:
Programmer Certification (OCPJP)
Question 58 Quiz B in master exam of K&B
Sanjay Singhaniya
Greenhorn
Posts: 25
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
It has a line mentioning
Arrays.asList(16,8,42,15,4,23)
I am getting compiler error on this stmt. But the answer to the question is not "compilation fails".
I have attached the screenshot.
Please explain.
58.jpg
Stephen Davies
Ranch Hand
Posts: 352
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You are correct, the code compiles and prnts 42. I suppose it is an error.
import java.util.*; public class PQ { public static void main(String[] args) { Comparator<Integer> cmp = new Comparator<Integer>(){ public int compare(Integer n1,Integer n2){ return n2.compareTo(n1); } }; PriorityQueue<Integer> q= new PriorityQueue<Integer>(100,cmp); q.addAll(Arrays.asList(16,8,42,15,4,23)); System.out.println(q.poll()); } }
be a well encapsulated person, don't expose your privates, unless you public void getWife()!
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
can I add Vectors together?
equals hashCode doubt from mock test
IBM WebSphere
Why we should prefer synchronization?
IBM 287 ICE TEST
More...