Hello ranchers !!!
i'm still preparing for OCPJP 6.0 exam, that occurs on this Friday, wish me luck on this, and for a moment doing enthuware mock exams, that mostly are excellent questions and well explained answers for them, but observing that some of questions are almost direct copy-paste from JLS, like here :
What will be the output of compiling and running the following program?
class CloneTest
{
public static void main(
String[] args)
{
int ia[ ][ ] = { { 1 , 2}, null };
int ja[ ][ ] = (int[ ] [ ])ia.clone();
System.out.print((ia == ja) + " ");
System.out.println(ia[0] == ja[0] && ia[1] == ja[1]);
}
}
You had to select 1 option:
a) It will not compile because Arrays cannot be cloned like this as clone() is not coderanch.
b) It will not compile because either clone() should be in try-catch block or main should have throws clause.
c) It will print 'false false' when run.
d) It will print 'false true' when run.
e) It will print 'true true' when run.
I will not mentioned here an answer, so any who prepares themselves to exam should try to figure it out ,
But if you would look on Example 10.7-2. Shared Subarrays After A Clone in JLS7, you will find identical code !
This is not first occurence of quite tricky questions, even that this one marked as Easy by enthuware , but i'm not totaly agree with this grade, that are originated by subtle understanding of JLS document.
From people that took already this exam or OCPJP 7.0 part 1 or 2 is it worthy investment of time to read carefully JLS document, which is not smallest in the world, and not easiest reading neither, 3 days before an exam ?
Any insight are welcome ...
Thanks