Question: JAVA Which of these statements does not match by using exception action in Java? 1. Exception action makes it possible for the calling method to

JAVA Which of these statements does not match by using exception action in Java?

1. Exception action makes it possible for the calling method to handle errors in called methods.

2. Exception action simplifies programming since incorrect reporting and handling can be located in catch blocks separately from the rest of the code.

3. Exception action increases the performance of programs.

4. Java separates exception action from common processes.

Why create instances of File Class? - several alternatives possible

1. To find properties of the file.

2. To delete the file

3. To read / write the content from / to the file.

4. To find out if the file exists. To rename the file.

Which of the following are correct?

I: try (PrintWriter output = new PrintWriter("output.txt")) { output.println("Welcome to Java"); } II: try (PrintWriter output = new PrintWriter("output.txt");) { output.println("Welcome to Java"); } III: PrintWriter output; try (output = new PrintWriter("output.txt");) { output.println("Welcome to Java"); } IV: try (PrintWriter output = new PrintWriter("output.txt");) { output.println("Welcome to Java"); } finally { output.close(); }

1. IV 2. I 3. II

4. III

Which of the following are correct?

I: File file = new File("input.txt"); try (Scanner input = new Scanner(file)) { String line = input.nextLine(); } II: try (File file = new File("input.txt"); Scanner input = new Scanner(file);) { String line = input.nextLine(); } III: File file; try (file = new File("input.txt"); Scanner input = new Scanner(file);) { String line = input.nextLine(); } IV: File file; Scanner input; try (file = new File("input.txt"); input = new Scanner(file);) { String line = input.nextLine(); }

1. III

2. II

3. I

4. IV

Suppose you have written 34.3 57.8 789 to the console and then pressed the Enter / Return button. Analyze the following example:

Scanner input = new Scanner(System.in); double v1 = input.nextDouble(); double v2 = input.nextDouble(); String line = input.nextLine();

1. The content of the line will be: '7', '8', '9'.

2. The content of the line will be: '', '7', '8', '9'.

3. The content of the line will be: '', '7', '8', '9', 'n'.

4 .The content of the line will be: '7', '8', '9', 'n'.

Which of the following can be used to write to temp.txt? - several alternatives possible

1. new PrintWriter("temp.txt")

2. new PrintWriter(temp.txt)

3. new PrintWriter(new File("temp.txt"))

4 .new PrintWriter(File("temp.txt"))

To create an InputStream for reading a file from a web server, you can use any of the following methods in the URL class.

1. openStream()

2. getInputStream()

3. connectStream()

4. obtainInputStream()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!