-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathTest - Objects and Classes
71 lines (61 loc) · 2.79 KB
/
Test - Objects and Classes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
1. What does OOP stand for?
A) Object-Oriented Programming
B) Object-Oriented Protocol
C) Object-Oriented Process
D) Object-Oriented Principles
2. Which of the following is true about a class in Python?
A) It is a blueprint for creating objects
B) It is a built-in data type
C) It represents a single instance of an object
D) It is a module for organizing functions
3. What is an instance in Python?
A) A built-in data type
B) A function within a class
C) A variable that holds a value
D) A concrete object of the class
4. What are attributes in the context of OOP?
A) Functions within a class
B) Variables that hold values
C) Statements that define class behavior
D) Keywords reserved for class definitions
5. What is the purpose of the __init__() method in a class?
A) To initialize an object's initial attributes
B) To define class attributes
C) To create a new instance of the class
D) To access variables that belong to the class
6. What does the self parameter represent in a method definition?
A) A reference to the current instance of the class
B) The class itself
C) The superclass of the class
D) The module containing the class
7. How can you modify the value of an attribute in an object?
A) By using the dot notation and assigning a new value to it
B) By defining a new method in the class
C) By reassigning the attribute in the class definition
D) By using the self keyword in a method
8. What happens when you change the value of an attribute in an object?
A) The change is reflected in all instances of the class
B) The change is only made for that specific instance
C) The attribute is deleted from the object
D) The attribute becomes read-only
9. What is the purpose of inheritance in OOP?
A) To create multiple instances of a class
B) To encapsulate data and behavior into objects
C) To reuse code and extend functionality
D) To define attributes and methods for a class
10. What is encapsulation in OOP?
A) The process of creating an object from a class
B) The ability to hide internal implementation details and provide an interface
C) The process of defining attributes and methods for a class
D) The ability to inherit attributes and methods from a superclass
Correct answers:
1. A) Object-Oriented Programming
2. A) It is a blueprint for creating objects
3. D) A concrete object of the class
4. B) Variables that hold values
5. A) To initialize an object's initial attributes
6. A) A reference to the current instance of the class
7. A) By using the dot notation and assigning a new value to it
8. B) The change is only made for that specific instance
9. C) To reuse code and extend functionality
10. B) The ability to hide internal implementation details and provide an interface