


Java smart flow interview written test questions including answers
Nov 19, 2019 pm 04:40 PM1 The following description of the stack is incorrect (B)
A. The stack is a first-in, last-out linear table (recommended learning: java programmer interview questions)
B. The stack can only store sequentially
C. The stack has a memory function
D. The insertion and sum of the stack During the deletion operation, there is no need to change the stack bottom pointer
2 For a linear table of length n, in the worst case, the correct number of comparisons corresponding to the following sorting methods is (D )
A. Bubble sort is n/2
B. Bubble sort is n
C. Quick sort is n
D. Quick sort is n(n-1)/2
3 After reading the following code, the correct statement below is (A)
public class Person{ int arr[] = new int[10]; public static void main( String args[ ]){ System.out.println(arr[1]); } }
A When compiling, Error
B is correct when compiling, but error will be generated when running
C Output is empty
D Output 0
4 After executing the following program The output result is (D)
public class Test { public static void main(String[] args) { StringBuffer a = new StringBuffer("A"); StringBuffer b = new StringBuffer("B"); operator(a,b); System.out.println(a+","+b); } public static void operator(StringBuffer x,StringBuffer y){ x.append(y); y=x; } }
A . A,A
B. A,B
C. B,B
D. AB ,B
5 The following are not persistent: (A)
A. Convert the object into a string and transmit it through the network, and receive the characters at the other end Restore the object from the string
B. Read the program data from the database
C. Read the program configuration information from the XML configuration file
D. The data is saved as a file
6 The output result of the following code is (C)
int x= 0; int y=10; do{ y--; ++x; }while(x<6); System.out.println(); }
A. 5,6
B. 5,5
C. 6,5
D. 6,6
7 The input sequence of a stack is 123, then none of the following sequences The sequence that may be the stack output is (C)
A. 2 3 1
B. 3 2 1
C. 3 1 2
D. 1 2 3
8. When n = 5, the return value of the following function is (D)
int foo(int n){ if(n<2) return n; return foo(n-1)+foo(n-2); }
A. 1
B. 8
C. 7
D. 5
9 Explain what a Servlet is and talk about the life cycle of a Servlet
Servlet is a server-side Java application that is platform- and protocol-independent and can generate dynamic Web pages. It acts as the middle layer between client requests (web browsers or other HTTP client programs) and server responses (databases or applications on the HTTP server).
Servlet is a server-side Java application located inside the Web server. Unlike traditional Java applications started from the command line, Servlet is loaded by the Web server. The Web server must contain a Java virtual machine that supports Servlet. The Servlet life cycle can be divided into four stages: loading and instantiation, initialization, service, and destruction.
When the client requests for the first time, it first determines whether the Servlet object exists. If it does not exist, the Web container creates the object and then calls the init() method to initialize it. The initialization method is only called once during the entire Servlet life cycle.
After completing the creation and instantiation of the Servlet object, the Web container will call the service() method of the Servlet object to process the request.
When the Web container is closed or the Servlet object is to be deleted from the container, the destroy() method will be automatically called.
10 What are the functions and uses of filters?For a web application, a filter is a component within the web container that filters specific request resource request information and response information. When a request comes, the web container will determine whether there is a filter associated with the information resource. If so, it will be handed over to the filter for processing, and then handed over to the target resource. When responding, it will be handed over to the filter for processing in the reverse order. , and finally returns it to the user's browser.
Common filter uses mainly include: unified authentication of user requests, recording and auditing of user access requests, filtering or replacing data sent by users, converting image formats, and processing response content. Compress to reduce transmission volume, encrypt and decrypt requests or responses, trigger resource access events, etc.
11 In 2006, someone worked for 24 consecutive days and earned a total of 190 yuan (daily wage of 10 yuan, Sunday wage of 5 yuan, and no pay for Sunday rest). It is known that he started working on a certain day in late January, and the 1st of this month happened to be Sunday. The day when this person finished working was February (C)A. 2 February 6th
B. February 14th
C. February 18th
D. February 21st
12 by There is a bus from point A to point B. The total journey time is 42 minutes. After arriving at the terminus, the driver will rest for at least 10 minutes and the bus will turn around. If there is a bus on line A and point B, there will be one every 8 minutes from both terminals ( (not necessarily at the same time), then this route needs at least two buses (C)A. 15
B. 14
C. 13
D.12
#13 In the 10 fruit plates numbered 1 to 10, each plate contains fruits, a total of 100 pieces. There are 16 in the first plate, and the sums of the fruits in the three adjacent fruit plates are equal. Find the maximum number of fruits in the 8th plate (A)A. 11
B. 12
C. 13
14. 14
14 A snail fell into a 20-meter-deep well. It climbed up 3 meters during the day and fell 2 meters at night. How many days does it take to climb out?
I climbed 3 meters on the first day, then fell 2 meters, actually climbed 1 meter;
On the second day, I started from 1 meter and climbed up 3 meters. , then fell 2 meters, actually climbed 2 meters;
On the third day, I started from 2 meters and climbed up 3 meters, then fell 2 meters, actually climbed 3 meters;
.......
On the eighteenth day, I started climbing 3 meters from 17 meters, which happened to be 20 meters. I reached
Correct answer: 18
15 Suppose there is an infinite amount of water in a pond. Now there are two empty kettles with capacities of 5 liters and 6 liters respectively. Ask how to use these two kettles to obtain 3 liters of water.
Answer: Fill the 5L bucket with water and pour all the water into the 6L bucket;
Fill the 5L bucket again and pour water into the 6L bucket until it is full. At this time, 4L water is left in the 5L bucket;
Empty the 6L bucket and pour the 4L water in the 5L bucket into the 6L bucket;
Fill the 5L bucket with water and pour water into the 6L bucket. If it is full, there will be 3L of water in the 5L bucket.
16 There are three lights in the room and three switches outside the room. You can’t see the situation inside the room from outside the room. You can only enter the door once. What method do you use to distinguish which switch controls which one? lamp.
Answer: First turn on the first switch, turn it on for a while and then turn it off, then turn on the second switch, enter the room and touch each lamp. The one that generates heat is the first switch. The light that lights up is the second switch, and the light that doesn't change is the third switch.
17 Two blind men each bought two pairs of black socks and white socks. The 8 pairs of socks were made of cloth and the same size. Each pair of socks was connected by a piece of trademark paper. A blind man accidentally mixed eight pairs of socks together and asked them how to retrieve two pairs of black socks and two pairs of white socks.
Answer: Divide each pair of socks into two.
Everyone takes one.
In this way, each person has four black socks and four white socks.
Everyone has two pairs of black socks and two pairs of white socks.
18 There is a square diamond at the door of each elevator from the first to the tenth floor. The diamonds are different sizes. When you take the elevator from the first to the tenth floor, the elevator door will open once on each floor. , can only hold one diamond in his hand, and asks how to get the biggest diamond.
Answer: The elevator will open on each floor, so take it on the first floor. When you get to the second floor, change it if it is bigger. If it is smaller, don’t change it. Keep going up like this. , after reaching the top level, you will get the biggest
The above is the detailed content of Java smart flow interview written test questions including answers. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

The settings.json file is located in the user-level or workspace-level path and is used to customize VSCode settings. 1. User-level path: Windows is C:\Users\\AppData\Roaming\Code\User\settings.json, macOS is /Users//Library/ApplicationSupport/Code/User/settings.json, Linux is /home//.config/Code/User/settings.json; 2. Workspace-level path: .vscode/settings in the project root directory

To correctly handle JDBC transactions, you must first turn off the automatic commit mode, then perform multiple operations, and finally commit or rollback according to the results; 1. Call conn.setAutoCommit(false) to start the transaction; 2. Execute multiple SQL operations, such as INSERT and UPDATE; 3. Call conn.commit() if all operations are successful, and call conn.rollback() if an exception occurs to ensure data consistency; at the same time, try-with-resources should be used to manage resources, properly handle exceptions and close connections to avoid connection leakage; in addition, it is recommended to use connection pools and set save points to achieve partial rollback, and keep transactions as short as possible to improve performance.

DependencyInjection(DI)isadesignpatternwhereobjectsreceivedependenciesexternally,promotingloosecouplingandeasiertestingthroughconstructor,setter,orfieldinjection.2.SpringFrameworkusesannotationslike@Component,@Service,and@AutowiredwithJava-basedconfi

itertools.combinations is used to generate all non-repetitive combinations (order irrelevant) that selects a specified number of elements from the iterable object. Its usage includes: 1. Select 2 element combinations from the list, such as ('A','B'), ('A','C'), etc., to avoid repeated order; 2. Take 3 character combinations of strings, such as "abc" and "abd", which are suitable for subsequence generation; 3. Find the combinations where the sum of two numbers is equal to the target value, such as 1 5=6, simplify the double loop logic; the difference between combinations and arrangement lies in whether the order is important, combinations regard AB and BA as the same, while permutations are regarded as different;

java.lang.OutOfMemoryError: Javaheapspace indicates insufficient heap memory, and needs to check the processing of large objects, memory leaks and heap settings, and locate and optimize the code through the heap dump analysis tool; 2. Metaspace errors are common in dynamic class generation or hot deployment due to excessive class metadata, and MaxMetaspaceSize should be restricted and class loading should be optimized; 3. Unabletocreatenewnativethread due to exhausting system thread resources, it is necessary to check the number of threads, use thread pools, and adjust the stack size; 4. GCoverheadlimitexceeded means that GC is frequent but has less recycling, and GC logs should be analyzed and optimized.

fixture is a function used to provide preset environment or data for tests. 1. Use the @pytest.fixture decorator to define fixture; 2. Inject fixture in parameter form in the test function; 3. Execute setup before yield, and then teardown; 4. Control scope through scope parameters, such as function, module, etc.; 5. Place the shared fixture in conftest.py to achieve cross-file sharing, thereby improving the maintainability and reusability of tests.

TheJVMenablesJava’s"writeonce,runanywhere"capabilitybyexecutingbytecodethroughfourmaincomponents:1.TheClassLoaderSubsystemloads,links,andinitializes.classfilesusingbootstrap,extension,andapplicationclassloaders,ensuringsecureandlazyclassloa

Use classes in the java.time package to replace the old Date and Calendar classes; 2. Get the current date and time through LocalDate, LocalDateTime and LocalTime; 3. Create a specific date and time using the of() method; 4. Use the plus/minus method to immutably increase and decrease the time; 5. Use ZonedDateTime and ZoneId to process the time zone; 6. Format and parse date strings through DateTimeFormatter; 7. Use Instant to be compatible with the old date types when necessary; date processing in modern Java should give priority to using java.timeAPI, which provides clear, immutable and linear
