Summer Special Flat 65% Limited Time Discount offer - Ends in 0d 00h 00m 00s - Coupon code: suredis

CIW 1D0-437 CIW PERL FUNDAMENTALS Exam Practice Test

Demo: 22 questions
Total 169 questions

CIW PERL FUNDAMENTALS Questions and Answers

Question 1

Assuming $a = 2, which of the following evaluates as false?

Options:

A.

"False"

B.

$a

C.

$a < 0

D.

1

Question 2

Consider the following program code:

$i = 15;

LOOP: for(; $i < 25; $i++)

{

if ($i % 2)

{

next LOOP;

}

print($i );

}

What is the result of executing this program code?

Options:

A.

The code will output the following:

15 2 4 6 8 10 12 14 16 18 20 22 24

B.

The code will output the following:

15 17 19 21 23 25

C.

The code will fail at line 2 because $i is not initialized.

D.

The code will output the following:

16 18 20 22 24

Question 3

Consider the program code in the attached exhibit. What is the result of executing this program code?

Options:

A.

The code will output the following:

20 100 Apple Grapefruit Orange

B.

The code will output the following:

Apple Grapefruit Orange 20 100

C.

The code will output the following:

100 20 Apple Grapefruit Orange

D.

The code will output the following:

Orange Grapefruit Apple 100 20

Question 4

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?

Options:

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

Question 5

Consider the following program code:

@stack = (10, 10..25);

push(@stack, yellow);

shift(@stack);

push(@stack, white);

print shift(@stack);

What is the result of executing this program code?

Options:

A.

The code will fail at line 3 because shift requires two arguments.

B.

The code will output the following:

11

C.

The code will output the following:

10

D.

The code will output the following:

white

Question 6

Running your Perl scripts with a d switch will perform which task?

Options:

A.

Invoke the Perl debugger

B.

Send standard error to a file

C.

Disable breakpoints

D.

Display a stack trace

Question 7

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?

Options:

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

Question 8

Which line of code represents the correct syntax to establish a reference to a database handle?

Options:

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");

Question 9

In the context of Perl user-defined subroutines, which statement is the most accurate?

Options:

A.

Variables declared using the my keyword are global in scope.

B.

Variables declared using the local keyword are only available to the subroutine from which they are declared.

C.

Variables declared using the my keyword are available to the calling subroutine.

D.

Variable declared using the local keyword are available to subsequently called subroutines.

Question 10

Consider the following statement:

@array1 = (9, "A", 0..9, "PERL");

Given this statement, @array1 consists of how many elements?

Options:

A.

13

B.

4

C.

12

D.

16

Question 11

The filehandle INPUT is associated with the file represented by $file. Which statement will close the filehandle INPUT?

Options:

A.

close (INPUT, $file);

B.

closeINPUT;

C.

INPUT(close, $file);

D.

close(INPUT);

Question 12

Assume $sth is a valid statement handle. Which of the following correctly outputs the data from the first three columns of a result set?

Options:

A.

while(@rcrds = $sth->fetch_array)

{

print($rcrds[0]\n);

print($rcrds[1]\n);

print($rcrds[2]\n); }

B.

while(@rcrds = $sth->fetch_array)

{

print($rcrds[1]\n);

print($rcrds[2]\n);

print($rcrds[3]\n);

}

C.

while(@rcrds = $sth->fetchrow_array)

{

print($rcrds[1]\n);

print($rcrds[2]\n);

print($rcrds[3]\n);

}

D.

while(@rcrds = $sth->fetchrow_array)

{

print($rcrds[0]\n);

print($rcrds[1]\n);

print($rcrds[2]\n);

}

Question 13

Consider the following program code:

%color = (sun => yellow, apple => red);

reverse(%color);

@colorKeys = sort(keys(%color));

foreach(@colorKeys)

{

print($color{$_} . );

}

What is the result of executing this program code?

Options:

A.

The code will output the following:

apple sun

B.

The code will output the following:

sun apple

C.

The code will output the following:

red yellow

D.

The code will output the following:

apple red sun yellow

Question 14

Consider the following program code:

@array = ("one", "two");

push(@array, "three");

shift(@array);

unshift(@array, "four");

pop(@array);

print($array[0]);

What is the output of this code?

Options:

A.

one

B.

two

C.

three

D.

four

Question 15

Which statement writes data to the filehandle OUTPUT?

Options:

A.

print "Here's my data.\n" > OUTPUT

B.

write OUTPUT "Here's my data.\n";

C.

write OUTPUT ">Here's my data.\n";

D.

print OUTPUT "Here's my data.\n";

Question 16

Consider the following program code:

$x = 150;

$y = "250";

if (($x + 100) == $y) { print("1 "); }

if ("250" == $y) { print("2 "); }

if ("250" eq $y) { print("3 "); }

if ($x lt $y) { print("4 "); }

if ($x ge $y) { print("5 "); }

What is the result of executing this program code?

Options:

A.

The code will output the following:

1 2 3 4

B.

The code will output the following:

1 3 4

C.

The code will output the following:

1 3 5

D.

The code will output the following:

1 2 3 4 5

Question 17

Consider the following program code:

@array = ("Y", "W", "X");

@array = sort(@array);

unshift(@array, "Z");

print(@array[0]);

What is the output of this code?

Options:

A.

W

B.

X

C.

Y

D.

Z

Question 18

Consider the following program code:

$var = 10;

package Alpha;

$var = 20;

{

package Beta;

$var = 30;

}

package Gamma;

$var = 40;

{

print $var;

}

What is the output of this code?

Options:

A.

10

B.

20

C.

30

D.

40

Question 19

Consider the following program code:

@array = ("ALPHA", "beta", "GaMmA");

sort(@array);

print("@array");

What is the output of this code?

Options:

A.

beta GaMmA ALPHA

B.

ALPHA GaMmA beta

C.

ALPHA beta GaMmA

D.

beta ALPHA GaMmA

Question 20

Consider the following program code:

@array = ("ALPHA", "beta", "GaMmA");

@array = sort(@array);

print("@array");

What is the output of this code?

Options:

A.

beta GaMmA ALPHA

B.

ALPHA GaMmA beta

C.

ALPHA beta GaMmA

D.

beta ALPHA GaMmA

Question 21

Consider the following program code:

1.$x = 100;

2.$y = "-25";

3.$sum = $x + $y;

4.

5.print $sum;

What is the result of executing this program code?

Options:

A.

The code will output the following:

100-25

B.

The code will output the following:

75

C.

The code will fail at line 3 because $y contains string data.

D.

The code will output the following:

125

Question 22

Which one of the following statements opens a file for appending?

Options:

A.

open(PASSWD, ">/etc/passwd");

B.

open(PASSWD ">/etc/passwd");

C.

open(PASSWD, ">>/etc/passwd");

D.

open(PASSWD "+>/etc/passwd");

Demo: 22 questions
Total 169 questions