Java written test questions (for everyone to practice only)

Comprehensive explanation of Java test questions, written test and computer test can be tried and analyzed, free to share, thank you for taking it away

Java exam real question explanation, trial practice and analysis https://www.bilibili.com/video/BV1Sm4y1R7aL?spm_id_from=333.999.0.0

1. Multiple choice questions (3 points for each question, 45 points in total)

1. The following legal Java identifiers are ( ) .

       A、 _cat                                               B 、 5books

       C 、 +static                                          D、 -3.14159

2. In ORACLE, which of the following symbols can be placed in front of a line in a file to mark a comment.

       A、!                                                      B、 $

       C、&                                                     D、#

3. Which of the following statements is correct ( ) .

       A. Threads in JAVA are non-preemptive

       B. Threads in JAVA cannot share data

       C. Each JAVA program has at least one thread, the main thread

       D. Threads in JAVA cannot share code

4. Which HTTP Method can be used to transfer large amounts of data?

       A、POST                                              B、PUT

       C、DELETE                                          D、HEAD

       E、 GET

5. Which of the following descriptions about the stack is wrong ( ).

       A. The stack is a first-in last-out linear list

       B. The stack can only be stored sequentially

       C , the stack has a memory function

       D. During the insertion and deletion operations on the stack, there is no need to change the bottom pointer of the stack

6. Regarding Map and List, the following statement is correct ( ).

       A. Map inherits List

       B. Map or List can be saved in List

       C , Map and List can only save the data fetched from the database

       D. The value of Map can be List or Map

7. What happens when you compile and run the following program:

publicclassHope {

publicstaticvoidmain(String argv[]) {

Hope h = newHope();

}

protectedHope() {

for (inti = 0; i< 10; i++) {

System.out.println(i);

}

}

}

       A. Compilation error, the constructor cannot be declared as protected

       B. Compile and run to output 0 to 10

       C , running error, the constructor cannot be declared as protected

       D. Compile and run to output 0 to 9

8. The following correct description of network communication is ().

       A. The TCP/IP protocol is an unreliable network communication protocol

       B. UDP protocol is a reliable network communication protocol.

       C. TCP/IP protocol is a reliable network communication protocol.

       D , UDP protocol is an unreliable network communication protocol

9. The types of Java programs are ().

       A , class (Class)                                        B , Applet

       C、Application                                          D、Servlet

10. String str = "123456789"; str = str.subString(1,3); the value in str after execution.

       A、 “23”                                                     B、 “123”

       C、”12”                                                      D、“234”

11. The output result of the following code is ( ).

int i = 10;

while ( i > 0 ){

i = i + 1;

if ( i = =10 ){ break; }

}

       A , while loop executes 10 times                               B , infinite loop

       C , the cycle is not executed once                                D , the cycle is executed once

12. Execute the following code result (  ).

for(int i=0;;){

System.out.println("This is"+i);

break;

}

       A , grammatical error, lack of expression 2 and expression 3         B , infinite loop

       C. The program outputs nothing                                  D. Output: this is 0

13. The surface code output result is (  ).

int i = 0, s = 0;

do {

if (i % 2 == 0) {

i++;

continue;

}

i++;

s = s + i;

while (i< 7);

System.out.println(s);

       A、 16                                                     B、 12

       C、 28                                                     D、 21

14. The scope of access modifiers is from large to small ().

       A、 private-default-protected-public

       B、 public-default-protected-private

       C、 private-protected-default-public

       D、public-protected-default-private

15. What is the command to modify the table structure in the SQL language?

       A、MODIFY TABLE                                 B、MODIFY STRUCTURE

       C、ALTER TABLE                                    D、ALTER STRUCTURE

2. Questions and answers (36 points in total)

       1.  List three common RuntimeException subclasses.

       2.  Briefly describe the two implementation methods of threads and their differences

       3.  How to use Document to get and assign values ​​from the page

       4. Briefly describe the occurrence of deadlock.

       5. Please explain the difference between constants and variables

       6. What is an identifier, and what are the rules for identifiers?

3. Programming questions (19 points)

       1. Program to calculate the date and time 10 days from the current time, and output the new date and time in the format of "xxxx year xx month xx day". (6 points)

       2. Write a program, input an email address, and then use regular expressions to verify whether the email address is correct. (6 points)

       3. Write a program to change the string "1981-09-19 09:07:27.727" into Date type data. (7 points)

Shangxuetang brings a brand-new Java300 course to students! Java zero-basic self-study Java must-have high-quality tutorial

Java300 episodes, hands-on teaching, attacking big factories https://www.bilibili.com/video/BV1qL411u7eE?spm_id_from=333.999.0.0

Guess you like

Origin blog.csdn.net/lghtdw1314/article/details/123269807