Hiển thị các bài đăng có nhãn Testing IT. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn Testing IT. Hiển thị tất cả bài đăng

Thứ Tư, 8 tháng 8, 2012

Trắc nghiệm kiến thức ngôn ngữ PERL

Trong bài này, chúng ta sẽ trắc nghiệm một số kiến thức cơ bản về ngôn ngữ PERL.

Câu 1. When you're pattern matching, you describe the pattern using:

1. A string in double quotes
2. A MySQL select statement
3. A regular expression
4. A template

Câu 2. Perl is:

1. A type of interactive web page
2. A programming language
3. An application program
4. A relational database

Câu 3. The printf format "%6.2f" displays a number …

1. At least six columns wide in total, with two figures after the decimal place
2. Exactly six digits before the decimal place, and two digits after
3. At least six digits before the decimal place, and two digits after
4. Exactly six columns wide in total, with two figures after the decimal place

Câu 4. The statement open (FH,"abc.txt"); 
 
1. opens the file abc.txt for overwriting
2. opens the file abc.txt for reading
3. contains an error, so won't compile
4. opens the file abc.txt for appending

Câu 5. When you create a variable, you may assume it starts off containing:

1. 1
2. You may not make any assumption
3. The boolean value "false"
4. A null string (or 0 arithmetically)

Câu 6. Which brackets do you use to change the order of precedence of operations?

1. Curly braces
2. Square brackets
3. Round brackets
4. You don't use brackets in Perl - you write in RPN (Reverse Polish Notation)

Câu 7. Which of the following tests if the string held in $qn includes the word "perl"?

1. if ($qn =~ /perl/) .....
2. if ($qn == "perl") ....
3. if ($qn = "perl") .....
4. if ($qn eq "perl") .....

Câu  8. Which of these is NOT available for Perl: \

1. Perl, legally, for free
2. Individual and site licenses
3. Full documentation of the language which you can print out yourself
4. A Carribean cruise in 2006 on which you can meet some of the Perl gurus.

Câu 9. Perl was first released in:

1. 1978
2. 1998
3. Perl hasn't yet been released
4. 1988

Câu 10. Which of the following is NOT a comment line in a Perl program?

1. # This is a comment
2. #/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/#/
3. ##########################################################
4. //////////////////////////////////////////////////////////

Câu 11. What is a file handle used for?

1. Reading binary data from a file into a scalar variable
2. Finding where a file is on the disc
3. Accessing a disc file or other input/output stream
4. Deleting, moving or renaming a file

Câu 12. The "%" operator returns:

1. The larger of two numbers e.g. 200 % 20 would return 200
2. A percentage of a number e.g. 200 % 20 would return 40
3. The remainder when one number is divided by another
4. The remainder when one number is divided by another e.g. 18 % 7 would return 5

Câu 13. What is Perl?

1. Practical Extraction and Report Language
2. Practice for Exclusive and Report Language
3. Practical Extraction and Report Learning
4. Practical Exclusive and Report Language

Câu 14. Which of the following is used in perl?

1. else if
2. elseif
3. elsif
4. elif

Câu 15. The $_ variable

1. holds the last pattern matched.
2. holds the output field separator.
3. identifies the current command line argument.
4. none of the above is correct.

Câu 16. The getdir command

1. Reads a single file name from an open directory handle.
2. Reads the rest of the file names from an open directory handle.
3. Only works after anopendir command.
4. Is not a perl command.

Câu 17. The value of the expression $yards += 10

1. is 10.
2. is true.
3. cannot be determined from the information given.
4. relies on which command line arguments were used.

Câu 18. $x = @y[2 .. 4]

1. assigns$x the third, fourth and fifth elements of the y array concatenated together.
2. assigns$y[4] to $x.
3. assigns$y[2] to $x.
4. assigns 3 to$x.

Câu 19. Which of the following commands will turn a scalar ($str)into an array of characters?

1. @a = split($str).
2. @a = split(/\s/, $str).
3. This task can be done in Perl but none of the above commands do it.
4. @a = split(/./, $str).

Câu 20. <ARGV>

1. more than one of the above is correct.
2. identifies any command line arguments starting with a-.
3. will read the standard input if no arguments are listed on the command line.
4. can be used to read each line in every file name listed on the command line.

Câu 21. How do you perform a forward declaration of a subroutine performed?

1. forward sub name;
2. sub name;
3. forward name;
4. sub name {};
5. sub {};

Câu 22. Sample Code 
 
Code: INSERT INTO names VALUES ('John') 
 
How do you use the DBI module to execute the above SQL statement? Assume $dbh is the return value from DBI->connect.

1. my $statement = $dbh->execute("INSERT INTO names VALUES ('John')");
2. my $statement = $dbh->sql("INSERT INTO names VALUES ('John')"); $statement->execute;
3. my $statement = $dbh->prepare("INSERT INTO names VALUES ('John')"); $statement->execute;
4. my $statement = $dbh->run("INSERT INTO names VALUES ('John')");
5. my $statement = $dbh->insert("INSERT INTO names VALUES ('John')"); $statement->finish;

Câu 23. Which regular expression deletes all tags specified as text enclosed by "<" and ">" from a document stored in a string, but deletes nothing else.

1. $string =~ s/<*&>//g;
2. $string =~ s/<\S*>//g;
3. $string =~ s/<\s*>//g;
4. $string =~ s/<.*?>//g;
5. $string =~ s/<.*>//g;

Câu 24. Which one of the following completely defines scalars?

1. A number, an array, or a associative array
2. A single string, number, or reference
3. A string, a lexical array, or a numeric value
4. A pointer, a stack, or a heap
5. An int, float, double, or char

Câu 25. Sample Code 
 
Code: @values = ( "value1", "value2", ("value3", "value4") ); 
 
How does Perl store the nested list shown above?

1. The list is stored as a hierarchical list.
2. The list is stored as a hash with the offsets as keys to the hash.
3. The list is flattened by removing all internal bracketing.
4. The list stores two values, "value1" and "value2", plus a pointer to the internal list.
5. The list stores two values, "value1" and "value2", plus two pointers to "value3" and "value4."

Câu 26. Sample Code 
 
Code: printSorted(\@list,dir => 'asc', type => 'numerical'); 
 
Many functions in perl take option lists such as the ones in the above code sample. 
 
Given the information shown above, what does the line in the printSorted subroutine that retrieves the parameters probably look like?

1. my (@data,$options) = @_;
2. my ($data,%options) = @_;
3. my ($data,$option1,$option2) = @_;
4. my ($data,$options) = @_;
5. my (@data,@options) = @_;

Câu 27. Which one of the following regexes matches between 1 to 4 ab's followed by a tab and an integer number?

1. (ab)+{4}\t\d*
2. ab[ababab]\t[0-9]
3. {ab,4}\t\d+
4. (ab)?[1-4]\t[0-9]*
5. (ab){1,4}\t\d+

Câu 28. Sample Code 
 
Code 1: Code: my @lines = grep /^hi/, @allLines; 
Code 2: Code: my @lines = (); foreach (@allLines) { push (@lines,$_) if (/^hi/); } 
 
What is the difference between the two snippets (Code 1 and Code 2) above?

1. In code 1, the operation occurs in one command; code 2 iterates each element in the array for matches.
2. In code 1, the elements of @lines are the indexes in @allLines, in which matches were found.
3. In code 1, the elements of "@lines" begin with the index in "@allLines", in which the match was found.
4. In code 2, no matches are found.
5. In code 1, "@lines" may not necessarily be in the same order; the original lines appear in "@allLines".

Câu 29. Which conditional statement is equivalent to "if (!<condition>)"?

1. unless (<condition>)
2. failure (<condition>)
3. fails (<condition>)
4. ifn (<condition>)
5. require (<condition>)

Câu 30. Problem You need to check to see what version of Perl a module you have written is running. You know that Perl versions earlier than 5.005 do not work properly with your module. Given the problem shown above, how do you check that the version of Perl is new enough?

1. Using "$|>=5.005"
2. Using "$]>=5.005"
3. Using "%INC{VERSION}>=5.005"
4. Using "$PERLVER>=5.005"
5. Using "gt;=5.005"
 
Editor: Vương Lan Kiều
Source: http://baomathethong.blogspot.com/
Copyrighted Content: Ezdia.com, Academictutorials.com

Chủ Nhật, 22 tháng 7, 2012

Trắc nghiệm kiến thức về bộ giao thức TCP/IP (P1/C6)

>>> Chương 5

1. In _______ delivery, both the deliverer of the IP packet and the destination are on the same network.

A) a connectionless

B) a direct

C) an indirect

D) none of the above 
 
2. In _______ delivery, the deliverer of the IP packet and the destination are on different networks.

A) a connection-oriented

B) a direct

C) an indirect

D) none of the above 
 
3. In _______ delivery, packets of a message are logically connected to one another.

A) a connectionless

B) a connection-oriented

C) a direct

D) none of the above 
 
4. In _______ delivery, a packet is not connected to any other packet.

A) a connectionless

B) a connection-oriented

C) a direct

D) none of the above 
 
5. In classful addressing, when a direct delivery is made, both the deliverer and receiver have the same _______.

A) IP address

B) hostid

C) netid

D) none of the above 
 
6. In classful addressing, when an indirect delivery is made, the deliverer and receiver have _______.

A) the same IP address

B) different netids

C) the same netid

D) none of the above 
 
7. In _______ forwarding, the full IP address of a destination is given in the routing table.

A) next-hop

B) network-specific

C) host-specific

D) default 
 
8. In _______ forwarding, the mask and destination addresses are both 0.0.0.0 in the routing table.

A) next-hop

B) network-specific

C) host-specific

D) default 
 
9. In _______ forwarding, the destination address is a network address in the routing table.

A) next-hop

B) network-specific

C) host-specific

D) default 
 
10. In _______ forwarding, the routing table holds the address of just the next hop instead of complete route information.

A) next-hop

B) network-specific

C) host-specific

D) default 
 
11. In ________ addressing, a typical forwarding module can be designed using three tables, one for each unicast class (A, B, C).

A) classful

B) classless

C) both a and b

D) none of the above 
 
12. In classful addressing, the class of the address can be found by shifting the copy of the address ____ bits to the right.

A) 32

B) 16

C) 28

D) none of the above 
 
13. In classful addressing we need a routing table with at least ______ columns.

A) 4

B) 3

C) 8

D) none of the above 
 
14. In classless addressing, we need a routing table with at least _______ columns.

A) 4

B) 3

C) 8

D) none of the above 
 
15. The idea of address aggregation was designed to alleviate the increase in routing table entries when using ________.
A) classful addressing

B) classless addressing

C) both a and b

D) none of the above 
 
16. The principle of ________ states that the routing table is sorted from the longest mask to the shortest mask.

A) first mask matching

B) shortest mask matching

C) longest mask matching

D) none of the above 
 
17. The use of hierarchy in routing tables can ________ the size of the routing tables.

A) reduce

B) increase

C) both a and b

D) none of the above 
 
18. _______ deals with the issues of creating and maintaining routing tables.

A) Forwarding

B) Routing

C) Directing

D) none of the above 
 
19. A _______ routing table contains information entered manually.

A) static

B) dynamic

C) hierarchical

D) none of the above 
 
20. A _______ routing table is updated periodically using one of the dynamic routing protocols.

A) static

B) dynamic

C) hierarchical

D) none of the above 
 
21. The input and output ports of a router perform the ________ layer functions of the router.

A) physical and data link

B) network

C) transport

D) none of the above 
 
22. The routing processor of a router performs the ________ layer functions of the router.

A) physical and data link

B) network

C) transport

D) none of the above 
 
23. The task of moving the packet from the input queue to the output queue in a router is done by _________.

A) input and output ports

B) routing processor

C) switching fabrics

D) none of the above

Kimlinh.dt@baomathethong.blogspot.com
Copyrighted Content: mcgraw-hill.com