• 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

ExamLab, final test, question 6

 
Ranch Hand
Posts: 623
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers!

I've just finished the final test from ExamLab (priceless software!) and bumped into this one. It's purpose is to put the elements into the code so that it is compile-free and runs without exceptions. My answer was marked as wrong because of the type result of DateFormat.parse(...). I've insert Object and in the solution there was a Date (check the attached image).

I've put this code into Eclipse, compiled, execute and either solution is in my opinion right - no compile time errors and no runtime exceptions.

My question is - in real exam (in drag and drops), is there EXACTLY only one right solution for the given task?

Thanks in advance for all replies. I'm going to take the OCPJP 6 exam on Friday (24.09.2010).

Cheers!
Screenshot-2.png
[Thumbnail for Screenshot-2.png]
 
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the answers should be as specific as possible. Object is wider than Date.
 
Ranch Hand
Posts: 317
Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Martin Vanyavchich is right. Asnwer should be more specific.

But in the exam the questions will not be tricky.
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The object returned over here is a Date object and it got implicitly typecasted to Object when you collected it in a Object reference. and now you cannot use the date object returned unless you type-cast it again.

if instead of DateFormat.parse(..), it was keySet() and you collect it in an Object, it would still compile:




but then you would have to typecast it again to Set, to retrieve the Set object from it, without explicit cast object 'o' is not of any use.


So, There can be more than one answers for drag and drop questions, but in your question, it should be collected in Date object only
 
Piotr Nowicki
Ranch Hand
Posts: 623
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my opinion it just lacks of some information or exemplary usage of the "x" object at the last line of "main" method, just like, i.e. x.getTime() which would prevent from such a problems.

I understand that the o type reference needs to be downcasted to the java.lang.Date object if you want to use it this way, BUT it wasn't the purpose of this task. There is no usage of the "x" in code. The purpose was just to make the code compile and run.


It's just the first time I see a D&D with multiple valid solutions, therefore I wanted to know if this situation can happen on the real exam.

I will follow the Martin Vanyavchich's "answers should be as specific as possible" advice, but I still think the code template it should be more precise... But then again, maybe I'm just too suspicious after having too much ExamLab questions? :-))

Thanks guys for your time!

Cheers!
 
Sheriff
Posts: 7136
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pedro,
This, of course, is an error - I'll correct this with the next upgrade. Thanks for the heads up.

Pedro Kowalski wrote:My question is - in real exam (in drag and drops), is there EXACTLY only one right solution for the given task?


No - there could be multiple correct solutions. But, marks will be given for any correct solution.

I'm moving this to mock exam errata forum.
 
Piotr Nowicki
Ranch Hand
Posts: 623
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Devaka.

BTW: Nice to meet the author of such a great learning platform which is available free - chapeau bas my friend! :-)

If it might help, I've bumped into one other thing in mock test nr 3, question 60.

Despite some error with layout (don't know if it's fault of my particular installation or is it a global error), after finishing the exam I've copied the program to the notepad and tried to analyze it. I think the answer should be C rather than B, which is "false", as that's the result of the code execution and also that's what the explanation tells us:

This return boolean value (false) (....) will be printed by the statement System.out.print(ob);



Cheers!
Screenshot.png
[Thumbnail for Screenshot.png]
 
Devaka Cooray
Sheriff
Posts: 7136
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Pedro,

I checked this with the current database, and this error was already resolved. I don't remember when I corrected that, though.
The layout problem is not only for you. The next upgrade will be soon available with a fix for that.
reply
    Bookmark Topic Watch Topic
  • New Topic