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 questionsDomain Technology Fundamentals
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.
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.
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.
Keep practicing
Take the free FC0-U71 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other FC0-U71 practice questions
- Question 1A user logs in with the same credentials across multiple websites. Which of the following…
- Question 2Which of the following hard drives has the largest capacity?
- Question 3Which of the following is reset when a workstation is turned off?
- Question 4A technician is reviewing log files to track the number of times that a specific user has…
- Question 5Which of the following internet services traditionally has the most challenges with laten…
- Question 6A user is unable to load the most recent version of a web page. The old page loads each t…
