聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽 聽聽

xiaoxiao2021-04-05  257

Java test 1:

Please write a method in a class. This method searches for a character exists in a character array. If there is, it returns this character in the first time in the character array (the serial number starts from 0), otherwise, return -1. The characters and characters to search are passed to the method in parameter form. If the incoming array is NULL, it should throw an ILLEGALARGUMENTEXCEPTION exception. Test whether the method is written correctly in a similar case in the MAIN method of the class, for example, the character does not exist, the characters are present, the incoming array is NULL, etc.

Java test 2:

Write a program that connects each element in an integer array to a string, for example, according to the array of [1] [2] [3] is "1, 2, 3" String.

Java test questions 3:

Write a program that first converts a string entered on the keyboard into a decimal integer and then prints the binary form corresponding to this decimal integer. The decimal number of tweel-inmes is to use this number by 2, the remainder is the lowest position of the binary number, then the resulting commercial is removed as 2, the remainder obtained is the low, so that the divisor is 0. In fact, as long as it understands the way to print a decimal number (continuously divided by 10, the remainder of the result is a bit, ten, one hundred), which is easy to understand the number of decimal turnover . This program should consider the input string cannot be converted into a decimal integer, and the reason for the failure of the conversion is that the number is too large, or contains a non-digital character.

Java test 4:

Please print out a decimal integer hexadecimal form with shift. Tip: Displace the integer in each 4 binary positions, the result is one of the hexadecimal numbers, and then according to one of the three methods below (as a job, you need to use each way ) Calculate a hexade of hexadecimal form corresponding to a hex value: 1) 0-9 Data directly plus characters '0', 9 or more value minus 10 after adding character 'a' 2 ) Define an array, which contains 0-f, and then use the value to calculate as the index number of the array, to obtain its corresponding hexadecimal data. 3) The Character.Fordigit static method can convert a hexadecimal number into its corresponding character representation, for example, returning character 'f' depending on the value 15.

Java test 5:

Please combine the regular expression and string.split method described in our "JavaScript web development" book, from "http://www.it315.org/get.jsp?usr=zxxxxxxx =123" like this URL address Extract the name and value of each parameter. It is important to pay attention to the regular expression in the regular expression.

Java test questions 6:

Write a program that implements the file backup, the program is scheduled to run the syntax: java mycopy

Java test 7:

Please write a package class for a character input stream. Pack the underlying character input stream via this packaging class, allow the program to read a text file (for example, a Java source file) via this packaging class, each of the reads There are line numbers and colons in front of the line.

Java test 8:

The first piece of the seventh lecture in JavaScript video is the free piece "Application of Regular Expression" provided on the website, says that when you import a text file saved with the area control relationship into the database, Some of the spaces should be replaced with a comma (,), that is, for text file content in the following format: start IP end IP area

-------------------------------------------------- -------------

61.54.231.245 61.54.231.245 Anyang City, Henan Province, New Century Network

61.54.231.246 61.54.231.246 Unknown area in Anyang, Henan Province

61.54.231.9 61.54.231.247 Anyang City, Henan Province, Hong Da Internet Cafe

61.54.231.248 61.54.231.248 Anyang Anyang Normal University, Henan Province

61.54.231.249 61.54.231.249 Anyang City, Henan Province, Black Spider Internet Cap (Near Teachers College)

Should be converted into the following format:

61.54.231.245, 61.54.231.245, Henan Anyang New Century Network

61.54.231.246, 61.54.231.246, unknown area in Anyang City, Henan Province

61.54.231.247, 61.54.231.247, Anyang City, Henan Province, Red Daisone

61.54.231.248, 61.54.231.248, Anyang Anyang Normal University, Anyang City, Henan Province

61.54.231.249, 61.54.231.249, Anyang City, Henan Province, Black Spider Internet Bar (Near Teachers College)

In the video tutorial, explain the regular expression replacement function using UltraEdit to complete the above conversion. From JDK1.4, the Java language provides related API classes and methods for handling regular expressions. In the JDK Help document, view the replaceAll method for the String class, you can see that this method supports regular expressions similar to UltraEdit. Features.

task:

Read the help of the string.replaceAll method, and the related hyperlink it provides, after understanding the usage of this method, write a Java program to automatically implement the above regular expression, save the A.TXT (download) and save the result to the result B.TXT file. In addition, when we use the following SQL syntax when you implement the IP area of ​​the IT315 website:

SELECT Region from IP Table Where WHERE User IP> Start IP and User IP

With this SQL statement, you can query the regional results corresponding to the user IP. Since the user IP is compared to the start IP and end IP, if the user IP is 9.1.1.1, then the result of the 61.54.231.245 is the former greater than the latter, because user IP's first character "9 "The first character" 6 "greater than 61.54.231.245.

Now please come up with a solution, let the SQL statement above can return the correct result. Tip: Change 9.1.1.1 into 009.001.001.001 and compared to 061.054.231.245.

Please press this idea to increase the regular expression of this change in your program. Note that the start IP and the four fields of the end IP may be 1 bit, 2 or 3 digits, for example, 61.5.23.1.

In the source program, you want to comment on the function of the program code, please submit the program of the program to us, please use the instructions for the program.

转载请注明原文地址:https://www.9cbs.com/read-132028.html

New Post(0)