Java Magazine, July/August 2018
ORACLE COM JAVAMAGAZINE JULY AUGUST 2018 79 fix this public RacingCar speed 180 public void accelerate int deltaSpeed speed deltaSpeed System out println The new speed is speed And this code Car c new RacingCar line n2 c accelerate 50 line n3 What is the result Choose one A The Car class fails to compile B Line n2 fails to compile C Line n3 fails to compile D The new speed is 140 is printed E The new speed is 230 is printed Answers Answer 1 Option A is correct This question investigates the evaluation order of expressions and how values are passed in method calls Java Language Specification section 157 tells us The Java programming language guarantees that the operands of operators appear to be evaluated in a specific evaluation order namely from left to right Because of this the result of the calculations must be predictable and option E must be incorrect Question 1 page 76
You must have JavaScript enabled to view digital editions.