🎴 Flashcard Mode

Programming Languages: Java, JCL, and Perl

Card1 / 20
Mastered0
Review0
QuestionClick to flip

Assume @list contains (“1”, “2”, “3”, “4”, “5” ). What is the content of @list after the following statement splice (@list, -1, 1, “test1”. “test2”);

AnswerClick to flip back
A
(“1”, “2”, “3”, “4”, “test1”, “test2”)
💡 Explanation:

The splice function with offset -1 targets the last array element. It removes 1 element ('5') from position -1 and inserts two new elements 'test1' and 'test2' in its place, extending the array to six elements.

Change Mode