🎴 Flashcard Mode

Java and Perl Programming Concepts Quiz

Card1 / 14
Mastered0
Review0
QuestionClick to flip

What will be the value of $size after executing the following code?my @a = (0, 1, 2);$#a = 0;my $size = @a;

AnswerClick to flip back
A
1
💡 Explanation:

Setting $#a = 0 truncates the array to only its first element (index 0), removing all other elements. The array @a now contains only one element (0). When an array is assigned to a scalar in Perl, it returns the number of elements in the array, so $size = 1.

Change Mode