Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 21 The block of statements thats executed if an exception is thrown is called an ____________________. 2 points Question 22 When you call a

Question 21 The block of statements thats executed if an exception is thrown is called an ____________________. 2 points Question 22 When you call a method with a parameter list, the arguments in the argument list a. must be coded in the same sequence as the parameters b. must be declared with the same data types as the parameters c. must have the same names as the parameters d. all of the above e. a and b only 2 points Question 23 You can divide the code for an application into logical parts by moving some of the code from the main() method to other ____________________. 2 points Question 24 Code example 5-1 import java.util.Scanner; import java.text.NumberFormat; public class WeightConverter { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String prompt = "Enter weight in lbs: "; boolean isValid = false; double weightInPounds = 0.0; while (!isValid) { weightInPounds = getDouble(sc, prompt); if (weightInPounds > 0) { isValid = true; } else { System.out.println("Weight must be greater than 0."); } } double weightInKilos = weightInPounds / 2.2; NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMaximumFractionDigits(2); String message = weightInPounds + " lbs equals " + nf.format(weightInKilos) + " kgs "; System.out.print(message); } public static double getDouble(Scanner sc, String prompt) { double d = 0.0; boolean isValid = false; while (!isValid) { System.out.print(prompt); if (sc.hasNextDouble()) { d = sc.nextDouble(); isValid = true; } else { System.out.println ("Error! Invalid decimal value. Try again."); } sc.nextLine(); } return d; } } (Refer to code example 5-1.) If the user enters two hundred at the console prompt, what does the code do? a. displays an error message from the main() method b. displays an error message from the getDouble() method c. figures the weight in kilograms d. throws an InputMismatchException 2 points Question 25 When you test an application, you typically start by using ____________________ data.

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

Genomes And Databases On The Internet A Practical Guide To Functions And Applications

Authors: Paul Rangel

1st Edition

189848631X, 978-1898486312

More Books

Students also viewed these Databases questions

Question

15-5 How will MIS help my career?

Answered: 1 week ago