FC0-U71 ยท Software development concepts
Functions and objects
Reusable functions with parameters and return values, and objects with properties and methods (object-oriented ideas).
Key points
- A function is a named, reusable block of code.
- It can take parameters (inputs) and may return a value to the caller.
- An object bundles related data (properties) with actions (methods) in one unit, for example a car with the property color and the method accelerate().
- A class is the blueprint, and each object created from it is an instance.
- Object-oriented methods organize programs around such objects.
Practice questions
What are the named inputs listed in a function's definition called?
- Properties
- Loops
- Constants
- Parameters
Show answer
Answer: D. Parameters
Parameters are the named placeholders for values a function receives. Properties belong to objects, and loops repeat code.
Which of these are properties (data) of a Car object?
- color
- currentSpeed
- fuelLevel
- start()
- brake()
Show answer
Answer: A. color, B. currentSpeed, C. fuelLevel
Properties store the state of an object: color, speed and fuel. start() and brake() are actions, so they are methods.
True or false: every function must return a value to its caller.
Show answer
Answer: False
False. Some functions only perform an action, such as printing a message, and return nothing useful.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
