Multiple choice technology programming languages

What will be the output? class A: def foo(self): print "Test" a = A() a.foo()

  1. Test

  2. Syntax error

  3. Value error

  4. Attribute error

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

In Python, names starting with double underscore are name-mangled. foo becomes _Afoo internally. Attempting to call a.__foo() from outside the class raises an AttributeError because the method name doesn't exist as written.