Question: 11. Suppose that a variable a is declared as double a = 3.14159. What do each of the following print? a. System.out.println(a); b. System.out.println(a +

11. Suppose that a variable a is declared as double a = 3.14159. What do each of the following print?

a. System.out.println(a);

b. System.out.println(a + 1);

c. System.out.println(8 / (int) a);

d. System.out.println(8 / a);

e. System.out.println((int) (8 / a));

Explain each outcome.

public class Hw2Ans11

{

public static void main(String[] args)

{

double a = 3.14159;

System.out.println(a);

System.out.println(a + 1);

System.out.println(8 / (int) a);

System.out.println(8 / a);

System.out.println((int) (8 / a));

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!