61.5k views
4 votes
It is not possible to safely check if an object has a certain attribute a.True b.False

User AKG
by
8.1k points

1 Answer

2 votes

Final answer:

The statement that it is not possible to check if an object has a certain attribute is false. Using Python language as an example, there is a built-in function called 'hasattr()' that returns True if the object has the specified attribute, otherwise it returns False.

Step-by-step explanation:

The statement is false. It is indeed possible to safely check if an object has certain attribute in programming languages. For instance, Python provides a built-in function called hasattr(), which returns True if the object contains the given attribute, otherwise it returns False. Here's a code snippet to illustrate:

class MyClass:
User Dvir Berebi
by
7.9k points

No related questions found