I/O · interview question
What does new File("data.txt") do if data.txt doesn't exist?
Multiple choiceMedium
Answer and explanation
Correct answer
A. It creates a File object representing that path; nothing is created or opened on disk.
Why
File (and Path) are just abstract pathnames. Use exists() / Files.exists(path) to check the disk.
References
Test yourself on I/O
A free test with instant, explained results. No account needed.