Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

OCA/OCP Practice Tests: OCP Practice Exam (two confused questions)

 
Ranch Hand
Posts: 221
27
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.
These questions are from "OCA/OCP Java SE Programmer Practice Tests" (J.Boyarsky & S.Selikoff) book, Chapter 23 OCP Practice Exam:


Question 44. Given an updatable ResultSet that contains the following and this code, what does the code snippet output?

---table skipped---


A. 0
B. 10
C. The code does not compile.
D. The code compiles but throws an exception at runtime.


In this question it isn't written that ResultSet is scrollable, says only updatable. If ResulSet is not scrollable the correct answer should be D, but the correct answer is A. Maybe "scrollable" was forgotten to be added.


Question 45. Which statements describe a java.io stream class and cannot be applied to a java.util.stream.Stream class? (Choose three.)

A. Can be used with try-with-resources statement
B. Includes a class or set of classes used solely for working with character data
C. Requires all data objects to implement Serializable
D. Some classes contain a flush() method.
E. Some classes contain a method to skip over data.
F. Some classes contain a method to sort the data.


Option A is shown as one of the correct answers in book and explanation says that:

Option A is correct because the java.io stream classes implement Closeable and can be used with try-with-resources statements, while java.util.stream.Stream does not implement Closeable.



But Stream class implements AutoClosable indirectly and can be used with try-with-resources statements.


Best regards
 
Marshal
Posts: 71655
312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please always provide full details of where the questions came from, so we can assess the complete question and to reduce copyright problems.

You are right that Stream extends AutoCloseable. Maybe you would like to show some code using that feature.
 
Campbell Ritchie
Marshal
Posts: 71655
312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know aboiut the reesult set being scrollable, sorry.
 
Mushfiq Mammadov
Ranch Hand
Posts: 221
27
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:Please always provide full details of where the questions came from, so we can assess the complete question and to reduce copyright problems.



Sorry, I edit the post. Thank you.
 
author & internet detective
Posts: 40359
819
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mushfiq. I've added both to the errata.

For the first, we did intend for the question to include scrollable. That was a good catch!

For the second, um. Oops?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic