2.6.2 Reading and Understanding Code 4. What is the output of this code sequence
ID: 3746705 • Letter: 2
Question
2.6.2 Reading and Understanding Code 4. What is the output of this code sequence? at double a -12.5; System.out.println( a); 5. What is the output of this code sequence? int a 6; System.out.println( a ); 6. What is the output of this code sequence? float a -13f; System.out.println( a ); 7. What is the output of this code sequence? double a 13/5; System.out.println( a ) 8. What is the output of this code sequence? int a 13/5; System.out.println( a ); What is the output of this code sequence? int a 13 % 5; System.out.println( a ); What is the output of this code sequence? int a 12 /6 2; System.out.println( a ); 9. 10. 11. What is the output of this code sequence? int a 12 (6 2): System.out.printIn( a) What is the output of this code sequence? int a 4+6/2 System.out.printin( a ) 12.Explanation / Answer
4.
Output -> 12.5 ( double precision number )
5.
Output -> 6 (integer)
6.
Output -> 13.0 (floating point number)
7.
Output -> 2.0 ( 13/5 = 2 as both are integers and then 2 is assigned to double which makes it 2.0)
8.
Output -> 2 (13/5 = 2 and here 2 is assigned to an integer)
9.
Output -> 3 ( 13%5 = 3 (remainder))
10.
Output -> 4 (12/6 * 2 = 2* 2 = 4)
11.
Output -> 1 ( 12/(6*2) = 12/12 = 1)
12.
Output -> 7 ( 4+6/2 = 4+3 = 7)
Do ask if any doubt. Please upvote.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.