nerdexam
Oracle

1Z0-819 · Question #27

Given: public class Main { public static void checkConfiguration(String filename) { File file = new File(filename); if(!file.exists()) { throw new Error("Fatal Error: Configuration File, " +…

The correct answer is C. Exception in thread "main" java.lang.Error:Fatal Error: Configuration File, App.config, is missing. See the full explanation below for the reasoning.

Question

Given: public class Main { public static void checkConfiguration(String filename) { File file = new File(filename); if(!file.exists()) { throw new Error("Fatal Error: Configuration File, "
  • filename + ", is missing."); } }
public static void main(String[] args) { checkConfiguration("App.config"); System.out.println("Configuration is OK"); } } If file "App.config" is not found, what is the result?

Options

  • AConfiguration is OK.
  • BThe compilation fails.
  • CException in thread "main" java.lang.Error:Fatal Error: Configuration File, App.config, is missing.
  • Dnothing

How the community answered

(26 responses)
  • A
    8% (2)
  • B
    19% (5)
  • C
    69% (18)
  • D
    4% (1)

Community Discussion

No community discussion yet for this question.

Full 1Z0-819 Practice