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.
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,...
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...
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
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
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:
6. What is short circuit evaluation? Give an example. 7. Briefly explain how operator precedence works...
6. What is short circuit evaluation? Give an example. 7. Briefly explain how operator precedence works in APL. 8. What does times do in Ruby? What about each? What about upto? Use code snippets to explain your answers. 9. What is a functional side effect? Give an example in code. 10. What is an unconditional branch statement? If you were to define a new language, would you include this construct? Why or why not?
1a. What 2 parts does every virus need? What is one optional part? 1b. Would a...
1a. What 2 parts does every virus need? What is one optional part? 1b. Would a virus that infects plants have an envelope? Why or why not? *can you please answer the question in your own words, I posted this before and it was all answered by copying&pasting things from the internet that did not fully answer the question -thank you in advance*