Questions on real exam I had

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
michalwadas
Posts: 6
Joined: Mon Aug 23, 2021 5:32 am
Contact:

Questions on real exam I had

Post by michalwadas »

I had few questions I did not know the answer.
Such like:
1. What kind of methods we have to override to serializable the ClassA?
1) readExternal
2) readExternal and writeExternal
3) writeExternal
4) none
I decided to choose option 4. Because if we will implements Serializable we don't need to override, correct?
But the question didn't mention about if our class implements Serializable or not.
What do you think?

2. -noverify
I'm not sure the whole question was but there was a command with -noverify at the end of the line
(i choose option which says it exists since java 1.0)
one answer was "It will run java with latest version"
non of the options points to anything which says "class will not be verify or something"

3. What will print the correct path path= "/something/something2"

a). path.getRoot().getParent()
b) path.getRoot().getRoot()
c) path.getParent().getRoot()
d) path.getParent().getParent()

I was confuse about this question, there is no exception at all, is that correct?
Can you explain me what will be the difference between them? I choose getRoot().getParent()

4. Something about checking if path isDirectory
BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class);
BasicFileAttributes attr = Files.readAttributes(path, FileAtttribute.class);
BasicFileAttributes attr = Files.readAttributes(path);
BasicFileAttributes attr = Files.readAttributes(path, "isDirectory");

So I guess the correct syntax is option "a"

Anyway, is there any chance to see which questions I did wrong on exam?

admin
Site Admin
Posts: 10045
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: Questions on real exam I had

Post by admin »

Thanks for sharing the details, michalwadas.

1. Correct. Serializable doesn't require you to implement any method.
2. The -noverify option is not on the exam and so, I don't think it affects the answer. It might be there just to confuse you. Most likely, the option that had -noverify is a wrong option.
3. Once you go to the root, you can't go back further. So, getRoot().getParent() will return null. So, basically, you have to see which method will return null and check if the code is trying to call methods on it to make sure there is no NPE.
4. Yes, option 1 is correct. The second parameter has to be a BasicFileAttributes.class (or its subinterfaces such as DosFileAttributes or PosixFileAttributes). There is no FileAttribute.class.

Unfortunately, no, there is no way to know which questions you did wrong.
If you like our products and services, please help us by posting your review here.

michalwadas
Posts: 6
Joined: Mon Aug 23, 2021 5:32 am
Contact:

Re: Questions on real exam I had

Post by michalwadas »

admin wrote:
Fri Dec 17, 2021 3:02 am
Thanks for sharing the details, michalwadas.

1. Correct. Serializable doesn't require you to implement any method.
2. The -noverify option is not on the exam and so, I don't think it affects the answer. It might be there just to confuse you. Most likely, the option that had -noverify is a wrong option.
3. Once you go to the root, you can't go back further. So, getRoot().getParent() will return null. So, basically, you have to see which method will return null and check if the code is trying to call methods on it to make sure there is no NPE.
4. Yes, option 1 is correct. The second parameter has to be a BasicFileAttributes.class (or its subinterfaces such as DosFileAttributes or PosixFileAttributes). There is no FileAttribute.class.

Unfortunately, no, there is no way to know which questions you did wrong.
Ad. 3
So the only reasonable option is getParent().getRoot(). But what about getParent().getParent() ? this method will point at let's say
parent of parent directory -> means it will point at same directory. What I want to say parent directory for parent directory is exactly the same directory?

admin
Site Admin
Posts: 10045
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: Questions on real exam I had

Post by admin »

getParent().getParent() will go two levels up. Without looking at the actual question details, it is difficult to say. But you can try running a simple program and see the values:

Code: Select all

import java.io.*;
import java.nio.file.*;
  
public class TestClass{
  public static void main(String args[])
   {
	String pString ="/whatever/whatever";
	Path path = Paths.get(pString);
  
        Path root = path.getRoot();
  
        System.out.println("Root Path: "+ root);

        System.out.println(root.getParent());
    }
}
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 24 guests