Q:

Which gets the name of the parent directory file "file.txt"?

0

Which gets the name of the parent directory file "file.txt"?


  1. String name= File.getParentName(\"file.txt\");
  2. String name= (new File(\"file.txt\")).getParent();
  3. String name = (new File(\"file.txt\")).getParentName();
  4. String name= (new File(\"file.txt\")).getParentFile();
  5. Directory dir=(new File (\"file.txt\")).getParentDir(); String name= dir.getName();

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Correct Answer:

String name= (new File("file.txt")).getParent();

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now