A programmer needs to create a reusable block of code within an object that calculates the total price of an order and provides the result to other parts of the application. Which of the following programming concepts should the programmer use?
The correct choice is a method. In object-oriented programming, a method is a procedure or function associated with an object that can perform actions and/or calculate and return data. In this scenario, the code block calculates and returns a value, which is a primary use case for a method. A constant is a value that cannot be altered, a Boolean is a data type with only two possible values (true or false), and an array is a data structure used to store a collection of items.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.