• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Online Mock exam 2 (Java OCA 8 Programmer I Study Guide)

 
Evgeny Kapinos
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys!

I've passed second online mock exam and have some remarks about it:

1. In question:
Which of the following are supported by Java?

Answer doesn't include option "F" (Pointers). But wait. What about NullPointerException? Seems Java supports Pointers in terms of Java. This answer really confuses me. I've read answer description few times, but I disagree with it. Yes, Java doesn't support pointer arithmetic (like in C++), but pointers in general Java supports.

2. In question:
Which of the following are true?
Answer is "B;D". But answer description says that only one answer is correct "B". So option
D. If statements that do not compile are removed, output contains two
seems to be a Typo.

3. In question:
What is the output of the following code?
Answer is "F" (A runtime exception is thrown). But LocalDate has no static method LocalDate.of(int, int). So, by answer description, it seems to be a Typo. Else, correct answer should be "E" (The code does not compile). And it is really does not compile in current version.

I hope my contribution will be useful
 
nick woodward
Ranch Hand
Posts: 370
11
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there are differences i believe between references and a pointers, although I'm no expert. java has the former, but no pointers.

*edit: here's a good answer: http://programmers.stackexchange.com/questions/141834/how-is-a-java-reference-different-from-a-c-pointer

having said that, maybe the JVM uses pointers under the hood, but i'd guess the class is just poorly named.

as for your other questions - without having the book, or a more complete description of the question and answer(s) it's hard to know exactly what you mean.
 
Evgeny Kapinos
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nick woodward wrote:there are differences i believe between references and a pointers, although I'm no expert. java has the former, but no pointers.

*edit: here's a good answer: http://programmers.stackexchange.com/questions/141834/how-is-a-java-reference-different-from-a-c-pointer

having said that, maybe the JVM uses pointers under the hood, but i'd guess the class is just poorly named.

as for your other questions - without having the book, or a more complete description of the question and answer(s) it's hard to know exactly what you mean.

Thanks for reply.

I've read your link. This is good answer. Also I've read about in Wiki Reference_(computer_science). This article says that Pointer is one of implementation of Reference. But not vise versa. Maybe NullPointerException really poor named. IMHO: Java uses pointers under the hood, so it "supports it". Tricky question about difference between Pointer and Reference is a good for ะก++ programmers.

Other questions (2, 3) seems to be Typo on online mock exams in sybex. I have no ability to create a link on certain question. So I've described only key features. It's enough to find them for guys who are responsible for uploading qestions to sybex.
 
Ci-Ci Thomson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the difference is that "support" usually implies that you can program that construct. In this case, Java only uses pointers under the covers but it does not allow you to create a pointer like you can in C/C++.

Ci-Ci
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Evgeny Kapinos wrote:I've passed second online mock exam

Congratulations!

Evgeny Kapinos wrote:1. In question:
Which of the following are supported by Java?

Answer doesn't include option "F" (Pointers). But wait. What about NullPointerException? Seems Java supports Pointers in terms of Java. This answer really confuses me. I've read answer description few times, but I disagree with it.

That's indeed a very debatable answer But although the word "pointer" is mentioned in the Java Language Specification, section 4.3.1. Objects and there's indeed a (poorly named) NullPointerException class (NullReferenceException would probably have been much better and more consistent), I agree with the correct answer in this mock exam: Java does not support pointers! Java uses reference variables (references), not pointers. Using a reference variable you can only invoke methods of an object or access its data members, but you can't change the actual memory address. Pointers are more lower-level and you could do some pointer arithmetic; Java references are a higher-level abstraction which restricts the programmer from manipulating the actual memory address (which is a good thing ).

Evgeny Kapinos wrote:2. In question:

Answer is "B;D". But answer description says that only one answer is correct "B".

Correct! The third if-statement uses the == operator to compare a StringBuilder and a String which is not allowed and you'll get a compiler error. So answer B is definitely a correct answer. If you remove this if-statement, the code prints nothing. So this question should only list B as the correct answer.

Evgeny Kapinos wrote:3. In question:

Answer is "F" (A runtime exception is thrown). But LocalDate has no static method LocalDate.of(int, int). So, by answer description, it seems to be a Typo. Else, correct answer should be "E" (The code does not compile). And it is really does not compile in current version.

You are spot-on! The method LocalDate.of requires 3 int parameters: of(int year, int month, int dayOfMonth). So the code snippet must be updated. Probably the value for the dayOfMonth parameter is missing and thus the correct statement would be LocalDate.of(2015, 5, 10). If you don't spot the runtime exception, you'll select answer A as the correct statement.

Hope it helps!
Kind regards,
Roel
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And I have a (minor) remark about the 2nd mock exam as well, so I'll add it here

There's a question asking about which exceptions are always thrown programmatically. And then it lists 5 different exceptions:
1/ ArrayIndexOutOfBounds should be ArrayIndexOutOfBoundsException
2/ IOException and NullPointerException have redundant parantheses at the end
3/ IOException is the only class which is fully qualified (not very consistent, but probably because it's also the only class which is not in the java.lang package)
 
Evgeny Kapinos
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel, thanks for reply. I think now all remarks are solved/covered. Have a nice day.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Evgeny Kapinos wrote:I've passed second online mock exam and have some remarks about it:

Congrats! Good luck on the actual exam. I expect you to do well as the mock exams are harder than the real exam.

I've noted both 2 & 3 from your comments. I'm creating a batch of online comments and then telling the publisher.

Roel De Nijs wrote:1/ ArrayIndexOutOfBounds should be ArrayIndexOutOfBoundsException
2/ IOException and NullPointerException have redundant parantheses at the end
3/ IOException is the only class which is fully qualified (not very consistent, but probably because it's also the only class which is not in the java.lang package)

Noted #1 and #2. The third was was intentional.
 
Evgeny Kapinos
Greenhorn
Posts: 6
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:Congrats! Good luck on the actual exam. I expect you to do well as the mock exams are harder than the real exam.


Hi Jeanne.

I've passed real exam with result 95%. For preparation I used only your guide + sybex online mock exams. I certainly can confirm that it is enough for preparation. It covers All major topics. Also questions really easiest. So guide creates credit for future.

[edit] it's not allowed to publicly discuss/mention actual questions, so it has been removed as a precaution (better safe than sorry)

Thanks a lot. Good job
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Evgeny Kapinos wrote:I've passed real exam with result 95%.

Congratulations! Maybe you could share your experiences about your preparation and used resources in another thread. You might even earn your 1st cow!
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Evgeny Kapinos wrote:I've passed real exam with result 95%. For preparation I used only your guide + sybex online mock exams. I certainly can confirm that it is enough for preparation. It covers All major topics. Also questions really easiest. So guide creates credit for future.

Congrats! I'm happy to hear you got such a great score. You actually did better than me. I got a 91%. (Partially because I misunderstood the scope of date coverage and was surprised to see some of those questions. And partially because my focus was different than someone studying for the exam. I did get a 98% on the OCAJP 7 which I prepared for like a candidate.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic