Perl Online Quiz


Advertisements

Following quiz provides Multiple Choice Questions (MCQs) related to Perl. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Q 1 - Which of the following data types are preceded by an "at" sign (@) in Perl?

A - Scalar

B - Array

C - Hashes

D - All of the above.

Answer : B

Explanation

Arrays are preceded by an "at" sign (@).

Q 2 - In which of the following variable context, assignment to an array or a hash evaluates the right-hand side in a list context?

A - Scalar

B - List

C - Boolean

D - Void.

Answer : B

Explanation

List − Assignment to an array or a hash evaluates the right-hand side in a list context.

Q 3 - Which of the following method remove the elements of @ARRAY designated by OFFSET and LENGTH, and replaces them with LIST, if specified?

A - splice @ARRAY, OFFSET [ , LENGTH [ , LIST ] ]

B - split @ARRAY, OFFSET [ , LENGTH [ , LIST ] ]

C - join @ARRAY, OFFSET [ , LENGTH [ , LIST ] ]

D - sort @ARRAY, OFFSET [ , LENGTH [ , LIST ] ]

Answer : A

Explanation

splice @ARRAY, OFFSET [ , LENGTH [ , LIST ] ] - This function will remove the elements of @ARRAY designated by OFFSET and LENGTH, and replaces them with LIST, if specified. Finally, it returns the elements removed from the array.

Answer : A

Explanation

Adding a new key/value pair can be done with one line of code using simple assignment operator.

Q 5 - Which of the following statement repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body?

A - while

B - until

C - for

D - None of the above.

Answer : A

Explanation

while loop − Repeats a statement or group of statements while a given condition is true. It tests the condition before executing the loop body.

Q 6 - Which of the following operator checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true?

A - ==

B - !=

C - <=>

D - >

Answer : D

Explanation

> − Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true.

Q 7 - Which of the following operator encloses a string with-in double quotes?

A - q{ }

B - qq{ }

C - qx{ }

D - enclose{}

Answer : B

Explanation

qq{ } − Encloses a string with-in double quotes.

Q 8 - Which of the following operator derefereces a variable?

A - --

B - ->

C - ..

D - ++

Answer : B

Explanation

-> − The arrow operator is mostly used in dereferencing a method or variable from an object or a class name.

Q 9 - Which of the following function deletes a file?

A - delete

B - unlink

C - seek

D - None of the above.

Answer : B

Explanation

unlink − used to delete a file.

perl_questions_answers.htm
Advertisements