1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
-Dominant- [34]
3 years ago
11

The 'parseInt' method of the 'Integer' class throws a 'NumberFormatException' when it is passed a String argument that it cannot

convert to an int. Given the String variable s (which has already been assigned a value), write the code needed to convert the value in s assigning the result to the integer variable i If a NumberFormatException is thrown, i should be assigned the value -1.
Computers and Technology
1 answer:
vekshin13 years ago
3 0

Answer:

Following are the code in the java language  

try // try block

{

i = Integer.parseInt(s); // converting into the integer  

}  

catch (NumberFormatException e) // catch block

{

i = -1; // initialized i to -1.

}

Explanation:

Following is the description of code.

  • Create a try block in that clock we convert the variable "s" into the integer by using the function  Integer.parseInt and storing in the variable "i".
  • if try block gives an error the console is directly going  in the second we create a catch block for that try block In this block we initialized the variable  i to -1.
You might be interested in
Three types of keys on the keyboard​
White raven [17]

Answer:

letter symbols numbers

Explanation:

6 0
3 years ago
Read 2 more answers
What is output when the CarTest application is run? Why?
erik [133]

Answer:

red

Explanation:

public class CarTest {

public static void main(String[] argvs) {

//below line will create an object of CarTest class Object

CarTest carTest = new CarTest();

//This will call runDemo method

carTest.runDemo();

}

public void runDemo() {

//Below line will create an object of Car class  with color blue and 4 wheel

Car c = new Car("blue", 4);

//Bellow Line will change the color from blue to red, see the logic writteen in chnageColor method definition

changeColor(c, "red");

//Below line will print the color as red

System.out.println(c.getColor());

}

public void changeColor(Car car, String newColor) {

//This line will set the color as passed color in the car object

car.setColor(newColor);

}

}

5 0
4 years ago
The field that uses technology to manipulate and use information to improve healthcare is known as:_______
Sergeu [11.5K]

Answer:

Health informatics

Explanation:

7 0
2 years ago
the impact of the global digital divide. According to the authors, countries that lag behind the rest of the world’s ICT capabil
kvasek [131]

Answer:

hi

Explanation:

5 0
3 years ago
Q4. Write down the JavaScript statements to perform the following tasks.
goldenfox [79]

Answer:

Explanation:

In Javascript, you can accept an input value by using the prompt() function and saving the input into a variable. In the following lines of code, I have declared the three variables at the beginning and then prompted the user to enter a value for each and saved the values in the correct variables. In Javascript length is a keyword so I used len instead.

let base, height, len;

base = prompt("Enter Base value: ");

height = prompt("Enter Height value: ");

len = prompt("Enter Length value: ");

5 0
3 years ago
Other questions:
  • A patent facilitates a government-approved technological monopoly by
    5·1 answer
  • In which of the following scenarios would it be best to use a for loop?
    6·1 answer
  • Suppose that we can improve the floating point instruction performance of machine by a factor of 15 (the same floating point ins
    13·1 answer
  • Write a program that asks the user for a CSV of the NYC Open Data Film Permits: There is a sample file for June 2019 film permit
    9·2 answers
  • Write a function findWithinThreshold that identifies the elements of a given array that are inside a threshold value. Takes the
    13·1 answer
  • Create a program that calculates the tip and total for a meal at a restaurant. Type the code into an IDLE IDE editor window and
    5·1 answer
  • Someone please make a random question with an easy answer because i need one more brainliest to UPGRADE!
    7·2 answers
  • Write a logical expression using only and, or and not that is equivalent to the Exclusive NOR (XNOR) gate on 2 inputs, called in
    15·1 answer
  • I'm bad i'm mrs puff doo doo doo yeah it's a holiday
    6·2 answers
  • How to use emojis on chromebook without on-screen keyboard
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!