• 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
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Another error in SCJP5 quiz by muppeteer?

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

there is a question in the quiz:



and possible answers:

a) ab666
b) ab
c) doesn't compile

right answer given: c.

But the code compiles (with warnings but still compile!!!). It just throws an exception at runtime because String and Integer are not mutually comparable.

And another case. There is a piece of code without a question and you have to choose 1, 2, 3, 4:




regards

Serg
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have a link to where we can find that test? Try sending a message to the author of the test.
 
Serg Masow
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The questions above are from a SCJP5 quiz included in Java.Inquisition, which can be found here:
http://enigma.vm.bytemark.co.uk/webstart.html
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can contact Matt Russel. He manages the mock exams on his application
 
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
import java.util.Set;
import java.util.TreeSet;
public class Testing123
{
public static void main(String... args)
{
Set t = new TreeSet();
t.add("a");
t.add("b");
t.add("666");
for(Object o:t)
System.out.print(o);
}
}

output : 666ab

Can any one expalin me why its showing as 666ab, it should show ab666.
 
Serg Masow
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

because in this example TreeSet uses the natural order for sorting of it's elements and digits are "lesser" as letters.

regards
Serg
 
Don't sweat petty things, or pet sweaty things. But cuddle this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic