Question

What is the result of 2^7 in Java? Why does it give this result? What would...

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?

Homework Answers

Answer #1

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)

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
What is the result of 2^7 in Java? Why does it give this result?
What is the result of 2^7 in Java? Why does it give this result?
java Give an example of a class that contains at least one class variable and at...
java Give an example of a class that contains at least one class variable and at least one class method. Explain why using a class variable and method rather than an instance variable and method would be the correct choice in the example you select.
what is type erasure? why does Java use it when dealing with templated generic classes? what...
what is type erasure? why does Java use it when dealing with templated generic classes? what does java do instead
The private methods of a class in Java are visible to its subclasses.? What implementation of...
The private methods of a class in Java are visible to its subclasses.? What implementation of Set would you use to get the objects in the order they were inserted?
7. Explain the term Crowding In. What does it refer to, why would it be considered...
7. Explain the term Crowding In. What does it refer to, why would it be considered beneficial, and does this mean there is no crowding out? (7 points)
When does variable costing and absorption costing give similar result ? What makes the result of...
When does variable costing and absorption costing give similar result ? What makes the result of the two methods differ? Give a short explanation
Java API Usage: Use the Java API documentation for Standard Edition 7 to answer the following:...
Java API Usage: Use the Java API documentation for Standard Edition 7 to answer the following: a) List the full prototype for the methods that must be coded if a class implements the java.util interface named Iterator. b) How many methods are in the class Track? c) What package is the class Track located in? I am asking for the signature of the method, which is the first line which tells the return data type, the name of the method,...
Define what a MIC > 32 µg/mL means. What result would be expected? What does the...
Define what a MIC > 32 µg/mL means. What result would be expected? What does the test result tell us about the strain?d
Java programming. 1) What, if anything, is wrong with the following Java code? void test(String x)...
Java programming. 1) What, if anything, is wrong with the following Java code? void test(String x) { switch (x) { case 1: break; case 2: break; case 0: break; default: break; case 4: break; } } Select one: a)Each case section must end with a break statement. b)The case label 0 must precede case label 1. c)There is nothing wrong with the Java code. d)The default label must be the last label in the switch statement. e)The variable x does...
Write a Java program to print the result of the following operations. Your program should contain...
Write a Java program to print the result of the following operations. Your program should contain 4 methods (for each of given data sets). Yes, methods here are not structurally necessary, this requirement is only for you to get practice writing methods. Test Data: a. -8 + 4.0 * 6 b. (11+9) % 9 c. 20 + (-3)*3.0 / 8 d. 5 + 14 / 3 * 2 - 7 % 3 Your program: