0

programming languages Online Quiz - 218

Description: programming languages Online Quiz - 218
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

Which modifier can be used when matching in Perl to ignore case?

  1. s

  2. v

  3. i

  4. c


Correct Option: C

Which function can be used to break up a string into more than one part based upon a separator?

  1. chop

  2. split

  3. divide

  4. parse


Correct Option: B

Which file test can be done to see if a file has the sticky bit set on it?

  1. -s

  2. -l

  3. -S

  4. -k


Correct Option: D

Within a loop, which operator immediately ends execution of the loop?

  1. next

  2. last

  3. redo

  4. leave


Correct Option: B

You want to close the directory handle EVAN. Which of the following should you use to accomplish this?

  1. close EVAN;

  2. closedir EVAN;

  3. close_directory EVAN;

  4. none of the above


Correct Option: B
Explanation:

To solve this question, the user needs to know how to close a directory handle in a programming language.

The correct option to close a directory handle in a programming language is closedir EVAN;.

Option A close EVAN; is incorrect because close is used to close a file handle, not a directory handle.

Option C close_directory EVAN; is incorrect because there is no such function or command in most programming languages.

Option D none of the above is incorrect because option B closedir EVAN; is the correct command to close a directory handle in most programming languages.

Therefore, the answer is: B. closedir EVAN;

Which function can be used to print a message to standard error, but not quit the program?

  1. warn

  2. alert

  3. tell

  4. notifiy


Correct Option: A

Your script has just read in a variable from the keyboard and you want to strip that variable of the newline character that came in. What operator should you use to perform this operation?

  1. tidy

  2. trim

  3. chomp

  4. slim


Correct Option: C

Which file test can be done to see if a file is a symbolic link?

  1. -s

  2. -l

  3. -S

  4. -k


Correct Option: B

Which Perl function can be used to launch a child process to run a program?

  1. split

  2. spin

  3. fork

  4. system


Correct Option: D

AI Explanation

To answer this question, you need to understand how Perl can launch a child process to run a program.

Option A) split - This option is incorrect because the split function in Perl is used to split a string into an array or a list based on a specified delimiter. It is not used for launching child processes.

Option B) spin - This option is incorrect because there is no built-in Perl function called spin. It is not used for launching child processes.

Option C) fork - This option is incorrect because the fork function in Perl is used to create a new process that is a copy of the current process. It is commonly used to create child processes, but it does not directly launch a program. The child process created by fork can then use exec or system to launch a program.

Option D) system - This option is correct because the system function in Perl is used to execute an external program. It launches a child process to run the specified program.

The correct answer is D) system. This option is correct because the system function in Perl can be used to launch a child process to run a program.

Which file test can be done to see if a file exists and has a nonzero size?

  1. -s

  2. -l

  3. -S

  4. -k


Correct Option: A

Within Perl, which operator is used to change the working directory?

  1. cd

  2. chdir

  3. pwd

  4. wd


Correct Option: B

What is the value of @list at the end of the following program? #!/usr/local/bin/perl @list=(1,2.3); &testsub(*list); Sub testsub{ Local (*sublist)=@_; $sublist[1] = 5; }

  1. (1,2.3)

  2. (1,5,3)

  3. Will produce error.

  4. (1,4,2)


Correct Option: B

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?

  1. The code will output the following:123

  2. The code will output the following: 3

  3. The code will output the following:23

  4. The code will output the following: 321


Correct Option: A

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

  1. $dbh = DBI::connect("dbi:mysql:myPhoneBook");

  2. $dbh = DBD:->connect("dbi::mysql::myPhoneBook");

  3. $dbh = DBD::connect("mysql:dbi:myPhoneBook");

  4. $dbh = DBI->connect("dbi:mysql:myPhoneBook");


Correct Option: D

What do the variable $? contains?

  1. Page length of a particular output file

  2. The input end-of-line character

  3. The return code returned by a command called by the system function.

  4. The error code generated by a system library routine


Correct Option: C

What do the variable $! contains?

  1. Page length of a particular output file

  2. The input end-of-line character

  3. The return code returned by a command called by the system function.

  4. The error code generated by a system library routine.


Correct Option: D

What argument to splice is equivalent to push (@array, @sublist) function call?

  1. splice (@array,0.0.@sublist);

  2. splice (@array, scalar(@array),0, @sublist);

  3. splice (@array, 1, 0, @sublist);

  4. None of Above


Correct Option: B

Which statement will print the capital attribute of the $kansas object?

  1. print ("capital"=>$kansas);

  2. print {$kansas}=>(capital);

  3. print (capital)<={$kansas};

  4. print $kansas->{"capital"};


Correct Option: D

Which function can be used to make sure your program exits with a nonzero status even if there a standard error?

  1. hash

  2. noexit

  3. nozero

  4. die


Correct Option: D

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

  1. W

  2. X

  3. Y

  4. Z


Correct Option: D
- Hide questions