What is the result of 2^7 in Java? Why does it give this result? What would you use to get the result you would have expected before taking this class?
What is the result of 2^7 in Java?
Answer is : 128.0
Why does it give this result?
Math.pow(2,7) return the double value.
Math.pow(first,second); first argument raised to the power of the second argument.
2*2*2*2*2*2*2 = 128.0 return double, Not integer.
What would you use to get the result you would have expected before taking this class?
System.out.println(2*2*2*2*2*2*2); 2 multiply by itself, 7 times( you get the integer result)
Get Answers For Free
Most questions answered within 1 hours.