Zookal
Zookal

We’d love to hear any feedback or comment from you!

© 2011-2021 Zookal Pty Ltd

View question and answer

From our collection of questions and answers
Engineering · Computer Science
Question details

JAVA PROJECT (PLEASE SHOW SOLUTION)

Create a NetBeans project for this activity.

Consider the following code. Our goal is to be able to print all the files in the given directory by completing the codes. Choose or create a folder with files in it. Add the directory in the <insert a folder here> section.

import java.io.___________;

public class FileIO {

    public static void main(String args[]) {

         File dir = new File(<insert a folder here>);

         ____________ items = dir.____________;

         for (File item : items) {

            System.out.println(item._____________);

         }

}

}

Test Stem / Question

Choices

5: In order to use the class and methods of File. What should we import?

A: File

B: FileClass

C: Files

D: Streams

6: In order to list all the files and directories inside the File instance, what method should you use in B?

A: listFiles()

B: getFiles()

C: getAllFiles()

D: getDirectories()

7: What is the return type of that method?

A: An array of File object

B: Collection of File object

C: An array of Object object

D: An Array of string directories

8: In D, we would like to get the absolute path of the Files. What method should you use?

A: getAbsolutePath()

B: getAbsoluteFilePath()

C: toAbsolutePath()

D: toAbsoluteFilePath()

9: Now that we have completed the code, try to run it. What is the result?

A: It listed all the path inside the directory.

B: Compiler error since we did not throw or catch an exception.

C: Compiler error since we did not use the try catch statements

D: Nothing

10: Going back to the code, we would like to check if there is a file present. What method should you use?

A: exists()

B: isPresent()

C: isAvailable()

D: isValidDirectory()

Answer
Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.

Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.Find step-by-step answers from expert tutors to questions asked by students like you. Start 14-day free trial.