www.HadoopExam.com

HadoopExam Learning Resources

Following are the Oracle Java and Oracle SQL Products Provided by HadoopExam Learning Resources
Free Core Java 1Z0-808 Training Java 1Z0-808 Questions and Answers Java 1Z0-809 Questions and Answers Questions for Oracle 1Z0-060 : Upgrade to Oracle Database 12c Administrator Oracle Database 12c: SQL Fundamentals

Question 4: You have been given below code, what is the expected result ?

Question 4: You have been given below code, what is the expected result ?

package com.hadoopexam;

import java.nio.file.Path;

import java.nio.file.Paths;

public class Welcome {

public static void main(String[] args) {

Path path1 = Paths.get("/my/./file/");

Path res1 = path1.resolve("file.txt");

Path path2 = Paths.get("/data/use/");

Path res2 = path2.resolve("/hadoop.txt/");

System.out.println(res1);

System.out.println(res2);

}

}

1. \my\.\file\file.txt

       \data\use\hadoop.txt

2. \my\.\file\file.txt

      \hadoop.txt

3. It will throw error : java.nio.file.InvalidPathException: UNC path is missing sharename:

4. java.nio.file.InvalidPathException: UNC path is missing sharename: //hadoop.txt/

Correct Answer : 2 Exp : If you used this kind of path on a Windows machine (a path starting with /) the path would be interpreted as relative to the current drive.

Path java.nio.file.Path.resolve(String other) 

Converts a given path string to a Path and resolves it against this Path in exactly the manner specified by the resolve method. For example, suppose that the name separator is "/" and a path represents "foo/bar", then invoking this method with the path string "gus" will result in the Path "foo/bar/gus".

Parameters:

other the path string to resolve against this path

Returns:

the resulting path

Throws:

InvalidPathException - if the path string cannot be converted to a Path.

See Also:

FileSystem.getPath

I have cleared my Java 1Z0-808 Certification exam with 92% using this simulator

I have cleared my Java 1Z0-809 Certification exam with 96% using this simulator

You have no rights to post comments

You are here: Home Oracle Java 1Z0-809 Question 4: You have been given below code, what is the expected result ?