You are on page 1of 4

Classes and Objects: Programmer-defined types, Attributes, Rectangles, Instances as return

values, Objects are mutable, Copying

Question: What is the primary purpose of a programmer-defined type (class)?


a) To organize data into a structure
b) To create built-in data types
c) To define global variables
d) To specify arithmetic operations

Question: In object-oriented programming, what are attributes within a class?


a) Functions that operate on objects
b) Variables that store data
c) Methods that modify global variables
d) Instances of a class

Question: Why might instances be returned by functions in object-oriented programming?


a) To create a new class
b) To initialize class attributes
c) To perform operations on the class
d) To manipulate global variables

Question: True or False: Objects are mutable in most object-oriented programming


languages.
a) True
b) False
Question: In the context of classes and objects, what does "copying" typically refer to?
a) Creating a new instance with the same data
b) Duplicating the entire class
c) Assigning a new variable to the class
d) Modifying the class attributes

Classes and Functions: Time, Pure functions, Modifiers, Prototyping versus planning

Question: What defines a pure function in programming?


a) A function that has no side effects
b) A function that modifies global variables
c) A function that operates only on integers
d) A function that returns a class instance

Question: What do modifiers do in the context of classes and functions?


a) They create new classes
b) They modify class attributes
c) They operate only on pure functions
d) They prototype new functions

Question: Prototyping versus planning is most relevant to:


a) Class definition
b) Function design
c) Object instantiation
d) Attribute assignment
Question: In the context of programming, what is a prototype?
a) A preliminary design of a function or class
b) An instance of a class
c) A pure function with no side effects
d) A modifier for class attributes

Question: Which of the following is a characteristic of a pure function?


a) Modifying global variables
b) Having side effects
c) Returning the same output for the same input
d) Operating on class instances

Classes and Methods: Object-oriented features

Question: What is encapsulation in object-oriented programming?


a) The process of copying objects
b) The bundling of data and methods that operate on that data
c) The creation of global variables
d) The act of prototyping new methods

Question: Inheritance in object-oriented programming allows:


a) A class to inherit properties and methods from another class
b) A class to create new classes
c) A function to inherit attributes from a class
d) A class to have multiple instances
Question: What is polymorphism in object-oriented programming?
a) The ability of a function to modify global variables
b) The use of pure functions only
c) The capability of a class to take multiple forms or have multiple behaviors
d) The process of copying entire classes

Question: What is a constructor in the context of object-oriented programming?


a) A function that modifies class attributes
b) A method for creating new instances of a class
c) A modifier for pure functions
d) An attribute that stores class data

Question: Which of the following is NOT a fundamental principle of object-oriented


programming?
a) Encapsulation
b) Polymorphism
c) Recursion
d) Inheritance

You might also like