- Perl Basics
- Perl - Home
- Perl - Introduction
- Perl - Environment
- Perl - Syntax Overview
- Perl - Data Types
- Perl - Variables
- Perl - Scalars
- Perl - Arrays
- Perl - Hashes
- Perl - IF...ELSE
- Perl - Loops
- Perl - Operators
- Perl - Date & Time
- Perl - Subroutines
- Perl - References
- Perl - Formats
- Perl - File I/O
- Perl - Directories
- Perl - Error Handling
- Perl - Special Variables
- Perl - Coding Standard
- Perl - Regular Expressions
- Perl - Sending Email
- Perl Advanced
- Perl - Socket Programming
- Perl - Object Oriented
- Perl - Database Access
- Perl - CGI Programming
- Perl - Packages & Modules
- Perl - Process Management
- Perl - Embedded Documentation
- Perl - Functions References
- Perl Useful Resources
- Perl - Questions and Answers
- Perl - Quick Guide
- Perl - Useful Resources
- Perl - Discussion
Perl Mock Test
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.
Perl Mock Test II
Q 1 - Which of the following method splits a string into an array of strings, and returns it?
A - splice @ARRAY, OFFSET [ , LENGTH [ , LIST ] ]
B - split @ARRAY, OFFSET [ , LENGTH [ , LIST ] ]
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?
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?
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 4 - Which of the following is correct about $[ Special Variable?
A - This special variable is a scalar containing the first index of all arrays.
B - Because Perl arrays have zero-based indexing, $[ will almost always be 0.
Answer : D
Explanation
All of the above options are correct.
Q 5 - Which of the following is correct about Hashes?
A - A hash is a set of key/value pairs.
Answer : D
Explanation
All of the above options are correct.
Q 6 - Which of the following function returns all keys of a Hash?
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?
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?
Answer : B
Explanation
exists − exists function, which returns true if the named key exists, irrespective of what its value might be.
Q 9 - How will you get the size of a Hash?
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.
Q 10 - How will you add a new key/value pair to a hash?
Answer : A
Explanation
Adding a new key/value pair can be done with one line of code using simple assignment operator.
Q 11 - How will you delete a key/value pair to a hash?
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?
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?
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?
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?
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?
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?
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?
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?
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?
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?
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?
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?
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?
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?
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 |