What is the output of Integer.parseInt("10", 2)? _____A. 1;B. 2; C. 10;D. Invalid statement;
Question
What is the output of Integer.parseInt("10", 2)? _____A. 1;B. 2; C. 10;D. Invalid statement;
Solution
The output of Integer.parseInt("10", 2) is 2. So, the correct answer is B. 2.
Here's the step by step explanation:
-
Integer.parseInt() is a method in Java that is used to convert a String into an integer.
-
The method takes two parameters: the string to be parsed and the radix (the base in mathematical numeral systems).
-
In this case, "10" is the string to be parsed and 2 is the radix.
-
Since the radix is 2 (which represents binary in numeral systems), the binary "10" is converted to decimal, which results in 2.
Similar Questions
Select the correct answerWhat is the output of the following program?public class Score{ public static void main(String[] args) { System.out.println((125/50.0)*Integer.parseInt("10") + 70); }}Options95.080Compilation errorRuntime error
xvii) Ifs = "123", which of the following will convert it into integer?(a) int a=integer(s);(c) int a =parseInt(s);(b) int a=im (s);(d) int a=Integer.parseInt(a);
Line 1 : int x = Integer.parseInt("5"); Line 2 : float pi=Float.parseFloat("3.14"); Line 3 : boolean status=Boolean.parseBoolean("TRUE");Line 4 : char c = new Character("X");Which of the above lines can cause compilation error?Select one:a.Line 2b.Line 3c.Line 4d.Line 1
public class Hello{ public static void main(String args[]) { int num = 190; String rev_num = " " ; while (num!=0){ int digit = num%10; rev_num = rev_num+digit; num = num /= 10 ; } System.out.println((Integer.parseInt(rev_num)));} } Exception in thread "main" java.lang.NumberFormatException: For input string: " 091" at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67) at java.base/java.lang.Integer.parseInt(Integer.java:654) at java.base/java.lang.Integer.parseInt(Integer.java:786)
Which of the following expressions produce a value of type int? Mark all that apply.1 point2 + 2Integer.parseInt("2")2 + 2.07 / 311 * (int) 0.25
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.