Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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: 69894
278
  • 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: 69894
278
  • 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: 40035
809
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?
 
Your buns are mine! But you can have this tiny ad:
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
    Bookmark Topic Watch Topic
  • New Topic