QUESTION 1
Consider the following statement:
$buffer = a string;
Also consider that a file named test.txt contains the following line of text: One line of test text.What is the
output of the following lines of code? $file = “test.txt”;
open (OUT, “<$file”) || (die “cannot open $file: $!”); read(OUT, $buffer, 15, 4);
print $buffer;

A. a strOne line of test
B. a stOne line of tes
C. a strOne line of tes
D. a stOne line of test

Correct Answer: B
QUESTION 2
Consider the following lines of code:
@array1 = (“apples”, “oranges”, “pears”, “plums”); foreach (@array1) {print “$_\n”};
What is the result of these lines of code?

A. apples oranges pears plums
B. apples oranges pears plums
C. apples
D. apples oranges pears plums

Correct Answer: D
QUESTION 3
Consider the following program code:
%hash = (small => 8oz, medium => 16oz,large => 32oz); @keys = sort(keys(%hash));
for ($i = 0; $i < 3; $i++) { print($hash{$keys[$i]}\n);

}
What is the result of executing this program code?

A. The code will fail at line 1 because a hash cannot contain both numeric and string data.
B. The code will execute without error but will output nothing.
C. The code will output the following: 32oz 16oz 8oz
D. The code will output the following: large medium small
Correct Answer: C
QUESTION 4
Which statement will print the capital attribute of the $kansas object?
A. print (“capital”=>$kansas);
B. print {$kansas}=>(capital);
C. print (capital)<={$kansas};
D. print $kansas->{“capital”};

Correct Answer: D
QUESTION 5
Consider the following program code:
@array = (10, Masami, 10..13, Niklas);
for ($i = 1; $i < $#array; $i++)
{
print($array[$i] );
}
What is the result of executing this program code?

A. The code will output the following: Masami 10 11 12 13
B. The code will output the following: 10 Masami 10 11 12 13
C. The code will output the following: 10 Masami 11 12 13 Niklas
D. The code will output the following: Masami 10 11 12 13 Niklas

Correct Answer: A
QUESTION 6
Consider the following program code:

$x = 10;
LOOP: while ($x < 15)
{
print ($x );
if ($x >= 14 && $x <= 20)
{
$x += 2;
redo LOOP;
}
else
{
$x++;
}
What is the result of executing this program code?

A. The code will output the following: 11 12 13 14 15 16 17 18 19
B. The code will output the following: 10 11 12 13 14 16 18 20 22
C. The code will output the following: 10 11 12 13 14 16 18 20
D. The code will output the following: 10 11 12 13 14 15 16 17 18 19 20
Correct Answer: B
QUESTION 7
Assuming $a = 2, which of the following evaluates as false?
A. “False”
B. $a
C. $a < 0
D. 1
Correct Answer: C QUESTION 8
Consider the following program code:
$y = 1;
$x = 2;
$z = 3;
do
{
print ($y );

} while ($y eq 2);
do
{
print ($x );
}
until ($x eq 2);
print ($z );
What is the result of executing this program code?

A. The code will output the following: 1 2 3
B. The code will output the following: 3
C. The code will output the following: 2 3
D. The code will output the following: 3 2 1

Correct Answer: A
QUESTION 9
Which line of code represents the correct syntax to establish a reference to a database handle?
A. $dbh = DBI::connect(“dbi:mysql:myPhoneBook”);
B. $dbh = DBD:->connect(“dbi::mysql::myPhoneBook”);
C. $dbh = DBD::connect(“mysql:dbi:myPhoneBook”);
D. $dbh = DBI->connect(“dbi:mysql:myPhoneBook”);

Correct Answer: D
QUESTION 10
Consider the following program code:
$val = 5;
if ($val++ == 6)
{
print(“True “);
}
else
{
print(“False “);
}
if ($val++ == 6)
{
print(“True “);
}
else

{
print(“False “);
}
What is the output of this code?

A. False False
B. False True
C. True False
D. True True

Correct Answer: B