Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming 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
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

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

 
Ranch Hand
Posts: 216
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: 65806
250
  • 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: 65806
250
  • 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: 216
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: 39530
776
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?
 
Good night. Drive safely. Here's a tiny ad for the road:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!