Perl Mock Test


Advertisements

This section presents you various set of Mock Tests related to Perl. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

Questions and Answers

Perl Mock Test II

Answer : B

Explanation

split [ PATTERN [ , EXPR [ , LIMIT ] ] ] - This function splits a string into an array of strings, and returns it. If LIMIT is specified, splits into at most that number of fields. If PATTERN is omitted, splits on whitespace.

Q 2 - Which of the following method joins the separate strings of LIST into a single string with fields separated by the value of EXPR, and returns the string?

A - splice EXPR, LIST

B - split EXPR, LIST

C - join EXPR, LIST

D - sort EXPR, LIST

Answer : C

Explanation

join EXPR, LIST − This function joins the separate strings of LIST into a single string with fields separated by the value of EXPR, and returns the string.

Q 3 - Which of the following method sorts the LIST and returns the sorted array value?

A - splice [ SUBROUTINE ] LIST

B - split [ SUBROUTINE ] LIST

C - join [ SUBROUTINE ] LIST

D - sort [ SUBROUTINE ] LIST

Answer : D

Explanation

sort [ SUBROUTINE ] LIST − This function sorts the LIST and returns the sorted array value. If SUBROUTINE is specified then specified logic inside the SUBTROUTINE is applied while sorting the elements.

Q 6 - Which of the following function returns all keys of a Hash?

A - keys

B - values

C - Both of the above.

D - None of the above.

Answer : A

Explanation

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

Q 7 - 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 8 - Which of the following function returns true if the named key exists in a Hash?

A - check

B - exists

C - Both of the above.

D - None of the above.

Answer : B

Explanation

exists − exists function, which returns true if the named key exists, irrespective of what its value might be.

Answer : A

Explanation

You can get the size − that is, the number of elements from a hash by using the scalar context on either keys or values.

Answer : A

Explanation

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

Answer : B

Explanation

To remove an element from the hash you need to use delete function.

Q 12 - Which of the following statement causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating?

A - next

B - last

C - continue

D - redo

Answer : A

Explanation

next statement − Causes the loop to skip the remainder of its body and immediately retest its condition prior to reiterating.

Q 13 - Which of the following statement terminates the loop statement and transfers execution to the statement immediately following the loop?

A - next

B - last

C - continue

D - redo

Answer : B

Explanation

last statement − Terminates the loop statement and transfers execution to the statement immediately following the loop.

Q 14 - Which of the following statement terminates the loop statement and transfers execution to the start of the loop?

A - next

B - last

C - continue

D - redo

Answer : C

Explanation

continue statement − A continue BLOCK, it is always executed just before the conditional is about to be evaluated again.

Q 15 - Which of the following statement restarts the loop block without evaluating the conditional again?

A - next

B - last

C - continue

D - redo

Answer : D

Explanation

redo statement − The redo command restarts the loop block without evaluating the conditional again. The continue block, if any, is not executed.

Q 16 - Which of the following statement jumps to the statement labeled with LABEL and resumes execution from there?

A - goto LABEL

B - goto EXPR

C - goto &NAME

D - None of the above.

Answer : A

Explanation

goto LABEL − The goto LABEL form jumps to the statement labeled with LABEL and resumes execution from there.

Q 17 - Which of the following statement expects the expression to return a label name and then jumps to that labeled statement?

A - goto LABEL

B - goto EXPR

C - goto &NAME

D - None of the above.

Answer : B

Explanation

goto EXPR − The goto EXPR form is just a generalization of goto LABEL. It expects the expression to return a label name and then jumps to that labeled statement.

Q 18 - Which of the following statement substitutes a call to the named subroutine for the currently running subroutine?

A - goto LABEL

B - goto EXPR

C - goto &NAME

D - None of the above.

Answer : C

Explanation

goto &NAME − It substitutes a call to the named subroutine for the currently running subroutine.

Q 19 - 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 20 - Which of the following statement repeats a statement or group of statements until a given condition becomes true. It tests the condition before executing the loop body?

A - while

B - until

C - for

D - None of the above.

Answer : B

Explanation

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

Q 21 - 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 22 - Which of the following operator divides left hand operand by right hand operand and returns remainder?

A - *

B - /

C - %

D - **

Answer : C

Explanation

% − Modulus − Divides left hand operand by right hand operand and returns remainder.

Q 23 - Which of the following operator performs exponential (power) calculation on operators?

A - *

B - /

C - %

D - **

Answer : D

Explanation

** − Exponent − Performs exponential (power) calculation on operators.

Q 24 - Which of the following operator checks if the value of two operands are equal or not, if yes then condition becomes true?

A - ==

B - !=

C - <=>

D - >

Answer : A

Explanation

== − Checks if the value of two operands are equal or not, if yes then condition becomes true.

Q 25 - Which of the following operator checks if the value of two operands are equal or not, if values are not equal then condition becomes true?

A - ==

B - !=

C - <=>

D - >

Answer : B

Explanation

!= − Checks if the value of two operands are equal or not, if values are not equal then condition becomes true.

Answer Sheet

Question Number Answer Key
1 B
2 C
3 D
4 D
5 D
6 A
7 B
8 B
9 A
10 A
11 B
12 A
13 B
14 C
15 D
16 A
17 B
18 C
19 A
20 B
21 C
22 C
23 D
24 A
25 B
perl_questions_answers.htm
Advertisements