1D0-437 - CIW Perl Fundamentals

Go back to CIW

Example Questions

The values function performs which task? Which one of the following choices lists only valid expression operators? Consider the following program code: $Animal = Dogs bark; package Cat; $Animal = Cats purr; { package Fish; $Animal = Fish swim; } package main; print $Animal; What is the result of executing this program code? 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? Consider the following program code: %employees = ("Lucy", "Accounting", "Armando", "Finance", "Adrienne", "Marketing"); delete($employees{"Lucy"}); Which of the following lines of code has the same effect as the preceding code? Which one of the following choices will assign the current package Library1? Consider the following program code: 1.$x = 100; 2.$y = 15; 3.$result = $x % $y; 4. 5.print $result; What is the result of executing this program code? 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? Consider the following lines of code: sub mySub { ( $arg, @args) = @_; foreach $val (@args) { $returnVal .= "$arg, $val\n"; } $returnVal . "" . @args; } print &mySub(1, "a value", "another value", "a parameter", "another parameter"); What is the output of these lines of code? Which of the following choices demonstrates the correct syntax for creating a hash? Which of the following accurately describes the roles of the Database Interface Module (DBI) and the Database Driver Module (DBD)? Consider the following statement: for ($count=0; $count < 5; $count++) {print "$count "} What will be the output from the given statement? Consider the following code: %chars = ("a", "100", "b", "90", "c", "80"); Which one of the following choices will reverse the key/value pairing of the code? Consider the following program code: if ("Apple" gt "Pear") { print("True "); } else { print("False "); } if ("Banana" le "Banana") { print("True "); } else { print("False "); } What is the result of executing this program code? 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? Consider the following command: perl runme.pl arg1 arg2 arg3 Given this command issued on the command line, what is the value of $#ARGV? Consider the following program code: @array = ("ALPHA", "beta", "GaMmA"); sort(@array); print("@array"); What is the output of this code? Consider the following command: perl runme.pl arg1 arg2 arg3 Given this command issued on the command line, what is the value of @ARGV? In Perl, packages are used for which task? 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? Assume $sth is a valid statement handle. Which of the following correctly outputs the data from the first three columns of a result set? Which one of the following choices lists valid assertions that represent places within a string? Consider the following lines of code: sub mySub { $_ = @_[1]; $a = shift; $b = shift; return $a * $b * $_; } mySub(1,2,3); What is the output of these lines of code? 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? Which one of the following choices uses the correct syntax for a valid array assignment? 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; Which of the following describes the functionality of the DBI tables method? Which of the following choices demonstrates the correct syntax to pass a reference to a subroutine? Which of the following choices demonstrates the correct syntax to pass the argument $arg2 to the subroutine getpass? Which statement is the most accurate? Consider the following lines of code: $_ = "This is a test"; s/^([^ ]*)\s*([^ ]*)/$2 $1/; print; What is the output of these lines of code? In Perl, modules are used for which task? Consider the following code block: BEGIN {print ("Jan ");} BEGIN {print ("Feb ");} END {print ("Mar ");} END {print ("Apr ");} Print ("May "); What is the result of this code block? Consider the following program code: print(1 ); BEGIN { print(2 ); } END{ print(3 ); } BEGIN { print(4 ); } END { package MyPackage; print(5 ); } What is the result of executing this program code? Consider the following statement: @array1 = (9, "A", 0..9, "PERL"); Given this statement, @array1 consists of how many elements? Consider the following assignments: $x = 9 $y = 7 $z = 5 Given these assignments, which one of the following expressions evaluates as true? Which of the following correctly creates a SQL statement that will insert the values of the $name and $age variables into a database? The statement is assigned to the $sqlStmt variable. Assume a CHAR data type for $name and an INT data type for $age. 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? Consider the following lines of code: @array1 = ("apples", "oranges", "pears", "plums"); foreach (@array1) {print "$_\n"}; What is the result of these lines of code? The filehandle INPUT is associated with the file represented by $file. Which statement will close the filehandle INPUT? Which one of the following statements opens a file for appending? Which one of the following while statements uses correct syntax and expressions? Consider the following program code: @array = ("ALPHA", "beta", "GaMmA"); @array = sort(@array); print("@array"); What is the output of this code? Regular expressions are best used for which task? 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? Yngve wants to define a character class that includes any alphanumeric word characters. Which one of the following choices is best suited for this requirement? Consider the following program code: @arrayA = (10, 20, 30); @arrayB = @arrayA; $arrayB[1] = 40; print $arrayA[1]; What is the output of this code? Which of the following is a valid subroutine name? Which of the following choices demonstrates the proper way to close a database connection given that $dbh is the database handle? Consider the following code: %hashA = ("alpha", "beta", "gamma", "alpha"); %hashA = reverse(%hashA); print $hashA{"alpha"}; What is the result of executing this code?