Win a copy of Head First Android this week in the Android forum!

Daniel Clinton

Ranch Hand
+ Follow
since Jun 05, 2014
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Daniel Clinton

Hi folks

Passed the 804 test during the week with 86%

I studied solidly for the test for the last 3 months
(actually since new year but less full-on)
I used K&B7 and Gupta books and then I made around 200 Anki flashcards and tried to get the vast amount of material into my head!!
If you stick at repeating them, the Anki cards do really work!
They come in handy for revising later too.

I sat the Enthuware and Whizlab practice tests and wrote out codes to explore ones where I was wrong or confused
Towards the end I used the leitner mode in Enthuware to move all the questions gradually over to the right hand column.
This is great if you have the time to do it.

The test itself was the same as (or a touch harder than) Enthuware level for me.
Having to do 66 Qs is so much more manageable than the 90 though!
I had about 30 mins to go over my marked ones

Thank you very much to JavaRanchers for much help this year
And thank you especially to Enthuware.
The test software and forum are a hugely helpful learning environment and preparation tool

Cheers folks

6 years ago
Hello Ganesan

I tried out the free trial exam software today. Looks great!
I have two questions.

I see the software simply marked which questions I got right and wrong.
In the full package for each completed question is there an explanation provided
of the right (and wrong) answers or a reference to relevant study materials/book?

Your webpage does mention a study ebook.
Would this be enough to prepare a student for learning all the exam objectives?

Thank you
Hi folks

When I return a map from the Files.readAttributes(Path, String, LinkOption...) method
as well as the expected 9 BasicFileAttributes and 4 DosFileAttributes
it contains an extra attribute named attributes associated with an Integer value (32)


lastModifiedTime : 2015-09-26T23:35:04.715864Z
lastAccessTime : 2015-09-26T23:23:23.587762Z
isSymbolicLink : false
size : 475
system : false
fileKey : null
isDirectory : false
hidden : false
isOther : false
isRegularFile : true
creationTime : 2015-09-26T23:23:23.587762Z
attributes : 32
archive : true
readonly : false

I found it to be available for reading by: But writing threw an exceptionException in thread "main" java.lang.IllegalArgumentException: 'dos:attributes' not recognized

What is this attribute "attributes"?
Hi folks

Does anyone know from past experience,
how quickly are Oracle's announced changes adopted?
If I'm doing my test next week should I expect 66 or 90 questions?

Hi folks

In the package java.util.concurrent.atomic,
AtomicInteger, AtomicLong, etc. do not implement Comparable<T>

Why is this?
You've placed an assignment to an existing variable where a class member definition is expected
If you want to assign a new value to the inherited field at time of object creation you can do so in an initializer.

Hope this helps
OCP Mock Exam 1
Exam 1 - Q.77 (public class ConcurrentModificator...)
Objective 11.0 Concurrency

Should not the answer be E as a RuntimeException (UnsupportedOperationException) would be thrown?

From the explanation:

D is correct.
A CopyOnWriteArrayList allows modifications while being iterated with an Iterator because the iteration happens on a reference of the List that reflects how it was when the Iterator was originated, which is why B is incorrect.

From CopyOnWriteArrayList javadoc:

The "snapshot" style iterator method uses a reference to the state of the array at the point that the iterator was created.
This array never changes during the lifetime of the iterator, so interference is impossible and the iterator is guaranteed not to throw ConcurrentModificationException. The iterator will not reflect additions, removals, or changes to the list since the iterator was created. Element-changing operations on iterators themselves (remove, set, and add) are not supported. These methods throw UnsupportedOperationException.

(This post originated in the K&B7 errata thread)
Hi folks

From Mala Gupta's guide, the Mock Exam Q.35

What are the subtype of List<?> . (Choose two correct options.)
a) List<String>
b) ArrayList<String>
c) LinkedList<?>
d) List<LinkedList>

Answer: a, d
Explanation: For any type T , List<T> is a subtype of List<?> .

Why ony a and d? I don't get it.
Are not each of the types List, ArrayList and LinkedList subtypes of List?
Can't references of all four parameterized types be assigned to a reference of type List<?>
What does subtype mean here?
Yeah they are the options.
Maybe it's intended to be 'source' rather than 'version'.

By the way, I did try compiling with javac from j2sdk 1.4.2 and it compiled fine
And then with Jdk 1.0.2 javac I got identifier expected compilation error for the Cache.class argument to the synchronized keyword??

Is this just a dud question or is there something I might learn about compiler or source versions?
Hi there folks

A question in Whizlabs I did was about javac versions
Which can successfully compile a class given a machine running SE 1.7.
Here is a similar class with same ideaThe options were compiling with
  • javac
  • javac -version 1.5
  • javac -version 1.2
  • javac -version 1.3

  • I took a guess that 1.5 (or 1.4) must have had some new feature, and went for the first two.
    This was right but the explanation didn't say why
    Is it the synchronized block?
    Or the use of the Cache.class lock?

    Instance methods bind at runtime according to the actual class of the object.
    Your object is of class C and so it is the send() method available in class C that is called.
    In your modified code C's send() is inherited from B.

    Also, if you remove the send() method of B, B will inherit from A, and C from B and ' AA' will be output.
    Hi Puspender

    In send() of C, by using super, you can access the overridden method of B (but not send() of A).
    C doesn't directly override send() in A and an instance of A would be needed to use the method.

    Your code throws a StackOverflowError due to looped calling of send()

    The reference to A produced by (A)this is valid but actually has no effect here
    because at runtime the send() of C is invoked and so it calls itself forever.
    Hi folks and java.nio.channels.FileChannel

    These 2 classes are not covered
    in the guides by Mala Gupta, Bates/Sierra or Sharma/Ganesh.
    But I've heard they definitely do appear in the exam.
    (Also the Enthuware tests also contain several questions on RandomAccessFile)

    I've tried to cover them with the API docs and
    the I/O trail from Oracle but their similarity/differences are confusing me.

    Here's where I've got to

    - construct an instance directly with a file name (File or String) and a file mode (String)
    - implements DataOutput and DataInput and thus has all the same readXXX and writeXXX methods of DataInputStream DataOutputStream
    - has a bytes pointer which is set with seek(long) and found with getFilePointer()
    - read and write anywhere

    - get an instance from getChannel() method of RandomAccesFile (or FileInputStream or FileOutputStream)
    or use the java.nio.file.Files factory methods to return a SeekableByteChannel (castable to FileChannel)
    - implements SeekableByteChannel which extends ByteChannel which extends Channel
    - has a position which can be set postion(long) and found with position()
    - read and write anywhere

    - other functionality like map to memory, lock region, force to storage, transfer to other channel

    I know FileChannel can do a lot more things but in terms of reading/writing freely to a file
    are these two classes just doing the same thing but one is using a Channel not a Stream?

    But then isn't a RandomAccessFile really like a buffer and not a Stream anyway?

    <scratches head, confused>
    Any help would be much appeciated
    Very helpful.
    Thank you Karthik

    Hi JavaRanch

    The following code returns a ResultSet from a database query
    It verifies the expected default ResultSet settings - TYPE_FORWARD_ONLY and CONCUR_READ_ONLY
    And then tries some scrollable operations

    Well, it compiles and appears to be scrollable.
    The output is:
    Forward only? true
    Read only? true
    And it then successfully reverses thru the rows printing the first column's String value

    The state of ResultSet.TYPE_FORWARD_ONLY
    is not causing SQLExceptions to be thrown for the stated methods in the javadoc
    Methods such as first() last() absolute(int) previous() relative(int)
    Why is this?

    (exceptions ARE thrown by methods requiring CONCUR_UPDATABLE
    such as moveToInsertRow() deleteRow() or UpdateXXX(...))