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 2 - Which of the following data types are preceded by a percent sign (%) in Perl?

A - Scalar

B - Array

C - Hashes

D - All of the above.

Answer : C

Explanation

Hashes are preceded by a percent sign (%).

Q 3 - Which of the following method shifts the first value of the array off and returns it, shortening the array by 1 and moving everything down?

A - push @ARRAY, LIST

B - pop @ARRAY

C - shift @ARRAY

D - unshift @ARRAY, LIST

Answer : C

Explanation

shift @ARRAY − Shifts the first value of the array off and returns it, shortening the array by 1 and moving everything down.

Q 4 - Which of the following function returns all values of a Hash?

A - keys

B - values

C - Both of the above.

D - None of the above.

Answer : B

Explanation

values − You can get a list of all of the values from a hash by using keys function.

Q 5 - Which of the following statement executes a sequence of statements multiple times and abbreviates the code that manages the loop variable?

A - while

B - until

C - for

D - None of the above.

Answer : C

Explanation

for loop − Executes a sequence of statements multiple times and abbreviates the code that manages the loop variable.

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

A - <

B - >=

C - <=

D - <=>

Answer : A

Explanation

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

Q 7 - Which of the following operator returns a string consisting of the left operand repeated the number of times specified by the right operand?

A - .

B - x

C - ..

D - ++

Answer : B

Explanation

x − The repetition operator x returns a string consisting of the left operand repeated the number of times specified by the right operand.

Q 8 - Which of the following function returns the current local time on the machine that runs the script?

A - localtime

B - gmtime

C - time

D - strftime

Answer : A

Explanation

localtime − returns the current local time on the machine that runs the script.

Q 10 - Which of the following function returns current position of a pointer in a file?

A - rename

B - tell

C - seek

D - None of the above.

Answer : B

Explanation

You can use tell function to know the current position of a file.


perl_questions_answers.htm

Advertisements