Question: 1. Given the following code: int a=5; int b=2; double d=a/b; System.out.println(d); a) What is the value of d when displayed on screen? b)

1. Given the following code: int a=5; int b=2; double d=a/b; System.out.println(d);

 

1. Given the following code: int a=5; int b=2; double d=a/b; System.out.println(d); a) What is the value of d when displayed on screen? b) Why is the valued shown as an integer when d is declared as double? c) Between the double and integer datatypes, which one is larger? d) How would you rewrite the 3rd statement of the code above for getting a double value going into d? e) What is the name of the process/action which makes a datatype behave like another?

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 Programming Questions!