What is the difference between following two segments of code<br /> <br /> Code 1<br /> <br /> int x = 4 * 3;<br /> int y = x * 5;<br /> <br /> Code 2<br /> <br /> int y = 4 * 3 * 5;<br /> <br />
Javasearch.buggybread.com

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Java - Interview Questions and Answers

 Q1. What is the difference between following two segments of code

Code 1

int x = 4 * 3;
int y = x * 5;

Code 2

int y = 4 * 3 * 5;

Core Java2017-05-12 09:26:49

Ans. Both will produce the same output but 1st will consume more resources in terms of memory ( for maintaining intermediate value ) and computing power ( as single mathematical calculation with more operands is more effective than multiple calculations with broken down operands )

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     


Related Questions

 What is GregorianCalendar class ?
 Why do we have multiple core java jars in java 9 ?
 Which of the Core Java functions / packages / concept do you believe have become irrelevant in today's market ?
 Explain difference between web-based application and Core Java Application ?



Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: