This week's book giveaway is in the
Agile and other Processes
forum.
We're giving away four copies of
The Mikado Method
and have Ola Ellnestam and Daniel Brolund on-line!
See
this thread
for details.
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Certification
»
Programmer Certification (SCJP/OCPJP)
Author
Question 58 Quiz B in master exam of K&B
Sanjay Singhaniya
Greenhorn
Joined: Feb 21, 2009
Posts: 25
posted
Feb 22, 2009 07:51:07
0
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
Joined: Jul 23, 2008
Posts: 352
posted
Feb 22, 2009 08:07:32
0
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()!
I agree. Here's the link:
http://ej-technologies/jprofiler
- if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
subject: Question 58 Quiz B in master exam of K&B
Similar Threads
can I add Vectors together?
equals hashCode doubt from mock test
IBM WebSphere
IBM 287 ICE TEST
Why we should prefer synchronization?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter