• Post Reply Bookmark Topic Watch Topic
  • New Topic

Another error in SCJP5 quiz by muppeteer?  RSS feed

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 16081
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
please buy this thing and then I get a fat cut of the action:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!