Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual Basic 4 Ole Database And Controls Superbible

Authors: Michael Hatmaker, C. Woody Butler, Ibrahim Malluf, Bill Potter

1st Edition

1571690077, 978-1571690074

More Books

Students also viewed these Databases questions

Question

mple 10. Determine d dx S 0 t dt.

Answered: 1 week ago