Java OCA OCP Practice Question 548

Question

How do you use the File class to list the contents of a directory?

  • A. String[] contents = myFile.list();
  • B. File[] contents = myFile.list();
  • C. StringBuilder[] contents = myFile.list();
  • D. The File class does not provide a way to list the contents of a directory.


A.

Note

The list() method returns an array of strings.




PreviousNext

Related