FC0-U71 practice question 16 of 25

A programmer creates an object to retrieve customer names from a database. Which of the following best describes the object that is retrieving the names?

Full set: 171 questions

Domain Technology Fundamentals

Answer options
A: Variable
B: Attribute
C: Method Correct answer
D: Looping
Correct Answer:
C. Method
Explanation

In object-oriented programming (OOP), an object encapsulates data and behavior. The behavior, or the actions an object can perform, is defined by its methods. The scenario describes an action: "retrieve customer names from a database." This process of fetching data is a function or procedure associated with the object. Therefore, the component that performs this retrieval action is a method. An attribute would store the data (the names) once retrieved, but the method is what executes the retrieval process.

Why Incorrect

A. Variable: A variable is a named storage location for data. The action of retrieving data is a process, not a storage location.
B. Attribute: An attribute (or field) represents the state or data of an object, such as a customer's name or ID. It does not perform an action.
D. Looping: Looping is a control flow statement (e.g., for, while) used to execute code repeatedly. A method might use a loop, but the loop itself is not the object component; the method is.

References

1. Oracle, The Java™ Tutorials, "Lesson: Classes and Objects," section "What Is an Object?". This official documentation states: "An object's behavior is exposed through its methods... A method is a function (or subroutine) associated with an object." This directly supports that an action like "retrieving" is a method.

2. Massachusetts Institute of Technology (MIT) OpenCourseWare, "6.0001 Introduction to Computer Science and Programming in Python, Fall 2016," Lecture 8: Object Oriented Programming. Slide 10 defines a method as "A function that is bound to an instance of a class" and explains that methods define the behaviors of an object.

3. University of Washington, Paul G. Allen School of Computer Science & Engineering, "CSE 142: Computer Programming I, Lecture 10: Objects." Slide 4, titled "Object state and behavior," explicitly lists "behavior (methods)" as what an object "can do" or actions it can take, contrasting it with "state (fields/attributes)" which is what the object "knows." The action of retrieving data falls under behavior.

Scroll to Top