Java Magazine, Sept/Oct 2018
ORACLE COM JAVAMAGAZINE SEPTEMBER OCTOBER 2018 83 fix this any subclass of NamedBuffer That constructor requires a single String argument Because of this when the code in the HugeNamedBuffer attempts to call a zero argument constructor none exists and compilation fails Therefore option C is correct and option D is incorrect Answer 2 The correct answer is option C This question investigates how values are passed into methods This topic is the essence of the Associate exam objective to determine the efect upon object references and primitive values when they are passed into methods that change the values Unlike some other languages Java is not a pure object oriented language in that eight data types known as the primitive data types are handled not as objects but as simple values Those types by the way are boolean byte short char int long float and double These types all have names that are entirely lowercase dont confuse them with their object wrapper counterparts Boolean Byte Short Character Integer Long Float and Double This distinction is not just esoteric it has a significant practical impact on how the language works and the efects that you might see when passing data into method calls When you call a method its often necessary to pass information from the caller to the method How that happens can have important consequences Consider this analogy Imagine a chef lets call her Rachel who is preparing a breakfast banquet Rachel has numbered file cabinets in her ofice and one of those cabinets contains her overall plan for the banquet including a uniquely numbered sheet on which she has written the quantity of pancakes required Rachel wants Jamie one of her assistants to make the pancakes Rachel might tell Jamie how many pancakes to make in either of two distinct ways She could copy the quantity of pancakes from her files onto a new piece of paper and hand that paper to Jamie Alternatively she could write the file cabinet and sheet numbers on a piece of paper hand that information to Jamie and invite Jamie to go into the file when she needs to know what to do Notice that these two techniques have diferent consequences if either Rachel or Jamie decides to change the quantity of pancakes If Jamie has the quantity written on her own paper there are two copies of the num Question 2 page 77
You must have JavaScript enabled to view digital editions.