178k views
1 vote
Which of the following can be used to get an integer value from the keyboard?

Integer.parseInt( stringVariable );
Convert.toInt( stringVariable );
Convert.parseInt( stringVariable );
Integer.toInt( stringVariable );

User Armster
by
4.7k points

2 Answers

1 vote

Answer:

A

Step-by-step explanation:

User Manan
by
5.2k points
5 votes

Answer:

Integer.parseInt( stringVariable );

Step-by-step explanation:

This function is used to convert the string into integer in java .Following are the program that convert the string into integer in java .

public class Main

{

public static void main(String[] args) // main method

{

String num = "1056"; // string variable

int res = Integer.parseInt(num); //convert into integer

System.out.println(res); // display result

}

}

Output:1056

Therefore the correct answer is:Integer.parseInt( stringVariable );

User Thatseeyou
by
4.9k points