Which gets the name of the parent directory file "file.txt"?
- String name= File.getParentName(\"file.txt\");
- String name= (new File(\"file.txt\")).getParent();
- String name = (new File(\"file.txt\")).getParentName();
- String name= (new File(\"file.txt\")).getParentFile();
- Directory dir=(new File (\"file.txt\")).getParentDir(); String name= dir.getName();
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