www.HadoopExam.com

HadoopExam Learning Resources

HadoopExam Training, Interview Questions, Certifications, Projects, POC and Hands On exercise access

    40000+ Learners upgraded/switched career    Testimonials

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

Visit Home Page : http://hadoopexam.com for more detail . As you are not blacklisted user.

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