CECS 277 Quizzes 1 - 12

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Which decorator is used to make a method abstract when inheriting from the ABC class?

@abc.abstractmethod

Which decorator tag is used to get the value of the attribute?

@property

What type of UML connection arrow does an interface use?

A dashed line with a white arrowhead

The class property of ___________ allows you to define an interface to interact with the objects of your class.

Abstraction

The Abstract Factory pattern is a ______________ design pattern.

Creational

T/F: Given an object: circle1 = circle.Circle(3) You can make a deep copy by doing: circle2 = circle1

False

T/F: A class that uses delegation can still be used polymorphically, and can be treated exactly the same as the delegate class.

False

T/F: An attribute with an underscore in front of the name means that it is public and you should access it directly.

False

T/F: An object is a blueprint for creating one or more classes.

False

T/F: Composition is when one class 'uses' an instance of another class.

False

T/F: Delegation uses inheritance rather than composition to gain the functionalities of another class, but only express the functions that are needed.

False

T/F: Dependency is when one class 'has' an instance of another class.

False

T/F: Functions can pass in another function as a parameter, but functions cannot return a function.

False

T/F: In Python 3, you need to directly specify that your class is inheriting from the object class to be able to override the special methods.

False

T/F: In the Decorator pattern, the concrete Component classes inherit from the Decorator class.

False

T/F: In the Object Adapter, the Adapter inherits from the incompatible Adaptee class.

False

T/F: Inheritance is bi-directional.

False

T/F: Mixins are a way to add additional behaviors to a class by forcing it to override all of its abstract methods.

False

T/F: Overloading the __plus__ function in your class will allow you to add another value to your object using the '+' operator.

False

T/F: Parameters are the values passed to a function when the function is called and Arguments are the variables defined in the function definition.

False

T/F: Something that is abstract is a real, physical item.

False

T/F: Structural design patterns provide a systematic way of creating and constructing objects.

False

T/F: The Adaptee class wraps around the Adapter class.

False

T/F: The Factory Method design pattern ensures that there is only ever a single instance of an object throughout the entire program.

False

T/F: The function "openfile" can be used to open a file for reading or writing.

False

T/F: The keyword except can be used to cause an exception in your program if you think one should occur, but normally wouldn't

False

T/F: The print function is used to write strings to a file.

False

T/F: The result of the operation: 3 // 2, is 1.5.

False

T/F: Unit tests are when someone checks your program to make sure that it is using the correct units (feet vs. meters, or pounds vs. kilograms).

False

T/F: When a function is defined within another function, the inner function is directly accessible from outside of the outer function.

False

T/F: When creating software, testing should only be done if there's extra time and resources.

False

T/F: You can create objects from an abstract class.

False

The Diamond Problem happens when you're using multiple inheritance and you don't override the superclass's methods.

False

In Delegation, the __________ acts as a proxy to the ____________.

Delegator, delegate

Which of the following class relationships is the following code an example of? class Dog: def speak(self): print("Arf Arf") class Trainer: def train_speak(self, dog): print("Spot... Speak!") dog.speak() print("Good dog.")

Dependency

Which of the following authors is not a member of the Gang of Four (GoF).

Knuth

Function parameters always appear within _______________?

Parenthesis

Which of the following functions will store the contents of the file as a list of strings?

Readlines

Given the following UML and class, what would be next after Purple in the Method Resolution Order? class Purple(red.Red, blue.Blue): def paint(self): print("Adding purple paint") Color Red Blue Purple

Red

Which of the following exceptions will be thrown if the index of a list goes out of bounds?

Index Error

T/F: A Mixin's relationship with another class can usually be identified as an 'includes-a' relationship.

True

T/F: A UML class diagram lists the attributes and methods of a class.

True

T/F: A base object is layered with a decoration by passing it to a decoration constructor.

True

T/F: A class is a programmer defined data type.

True

T/F: A decorator is a function that is passed another function to expand on the latter function's behaviors.

True

T/F: A try/except block is used to handle exceptions in your code.

True

T/F: Asserts are used to verify that your values are correct.

True

T/F: Class design is the process of figuring out what will become attributes and what will become methods.

True

T/F: Debuggers have breakpoints, which allow you to tell the program where to pause the execution.

True

T/F: Debugging is the process of stepping through your code to find the source of a bug.

True

T/F: Delegation is when one class assigns a task to another class.

True

T/F: Design Patterns are general solutions to common problems in software design.

True

T/F: Duck typing means that you can treat any objects that have a method or attribute in common the same way.

True

T/F: Exceptions are problems in your code that cause your program to crash.

True

T/F: If statements allow you to make decisions in your code.

True

T/F: In Python, you can inherit from the ABC class to make your class abstract.

True

T/F: In a UML diagram, a white diamond is used to show Aggregation.

True

T/F: In multiple Inheritance, the subclass needs to separate each class it's inheriting from by a comma.

True

T/F: In the Factory Method pattern all Concrete Product classes should implement the abstract Product interface.

True

T/F: Inheritance is when one class is derived from another class.

True

T/F: Interfaces are a way to add additional behaviors to a class by forcing it to override all of its abstract methods.

True

T/F: Multiple Inheritance is when a class inherits from two or more classes.

True

T/F: Multiple classes can inherit from a single class.

True

T/F: Numbers should be converted into strings when writing the values to the file.

True

T/F: Polymorphism is the ability of an object to take on multiple forms.

True

T/F: Properties allow you to create methods that behave as attributes.

True

T/F: Testing is the process of verifying that your program works the way it is supposed to.

True

T/F: The Abstract Factory pattern is used to construct families of related products.

True

T/F: The Adapter pattern allows objects with incompatible interfaces to work together.

True

T/F: The Decorator pattern allows you to attach additional behaviors on to an object.

True

T/F: The keyword def is required to create a function.

True

T/F: The print() function is used to display values to the console.

True

T/F: The property() function passes in the methods that it should call whenever the attribute is accessed.

True

T/F: To write to a file, you can provide the 'w' or 'a' argument when opening the file to write or append to the file.

True

T/F: Variable scope is the areas in your code where a variable can be accessed.

True

T/F: When opening a file, you should provide a string with the file name and, when necessary, the file path.

True

T/F: Writing data to a file allows you to store data long term.

True

T/F: You can override the __new__ method to set the instance when making your class a Singleton.

True

The *args parameter unpacks its contents into a __________, and the **kwargs parameter unpacks its contents into a ___________.

Tuple, dictionary

Which of the following string functions uses a delimiter to break up a string and returns a list of strings that are divided by that delimiter?

Split

Both Decorator and Adapter are _________________ design patterns.

Structural

In the Decorator pattern, the Decorator class _______________________.

both implements and has an instance of the Component

Which of the following functions would be used to overload the greater than operator?

__gt__(self, other)

Method overriding is when a method in the __________ has the same name as a method in the _________, but it has more refined functionality.

subclass, superclass

Which of the following methods will allow you to call the methods of the superclass?

super()

Which data type is used for decimal values?

Float

The AAA pattern of formatting unit tests stands for:

Arrange, Act, Assert

The assert method: assertGreaterEqual(a, b), has the equivalent logic of which of the following?

a >= b


Set pelajaran terkait

INS relative au service général et a la sécurité des casernement

View Set

QuickBooks Certification Test Answers 2023

View Set

Honors Physics Exam Review pt. 1

View Set

Google for Education Docs & Drive

View Set