3 ms·
question 2 of 6 for duck: Write code to trap these exceptions and return 1 if a FineException is thrown and return 0 if a CoarseException is thrown. int exce
by ismarc 16y ago
question 2 of 6 for duck:
Write code to trap these exceptions and return 1 if a FineException is thrown and return 0 if a CoarseException is thrown.
int exceptionTrap(int a) {
try {
exceptionThrower(a);
} catch (FineException fe) {
return 1;
} catch (CoarseException ce) {
return 0;
}
return -1;
}
You're saying the above is invalid? Tests out perfectly fine on my system...are you trying to say there shouldn't be the last return because you say "You may assume that an exception is always thrown"? If a function returns a type of int, all codepaths then need to return a type of int, programming 101.
Others indeed do have some errors as I quickly typed them up (off by 1, forgetting that java array length isn't the same as C++ std::vector.size). Number 3 could definitely use a better example, such as a = 12 (so the result would be {12, 11, 10}.
I admit, I checked number 2 closely, saw a horribly invalid failure reported and only glanced over the rest. Independent of the other failures, you cannot have incorrectly graded questions, and the rest of the points still stand, the requester has nothing to compare against, leaving the judgement up to your pass/fail (which is clearly not 100%) and the random assignment of questions to different test takers results in no real comparison ability between skills.
- deleted 16y ago[deleted]
- nps 16y agoYou're right about question 2, my apologies. There indeed was a bug in the test data for that question (which we have fixed now). However, the rest of the questions given in the test work properly. The reason different test takers get (somewhat) different question sets is because our algorithm alters the difficulty of the questions based on the test taker's performance. I.e. if you did the first few questions well, you'd start getting progressively tougher questions. On the other hand, if you do badly, you'll be given successively easier questions.