Multiple choice technology programming languages

package A; sub NEW { bless {}, shift } sub AUTOLOAD { print ref(shift) } package main; my $obj = NEW A; $obj->foo();

  1. A

  2. AA

  3. Can't locate object method "foo" via package "A"

  4. none of the above

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

In Perl, the bareword construction NEW A acts as a method call A->NEW(). Inside AUTOLOAD, calling ref(shift) prints the reference package name A twice: first for the invalid method call foo(), and a second time when the object goes out of scope and triggers the DESTROY method.