During this period of time, I was busy with work and didn't use much technology. I felt that the company's testing was still based on business and supplemented by technology. Technology is only a means to improve efficiency, but now it is a myth that no matter what position you are testing, you need to have a code base.
Complaining is complaining. Since the general environment is like this, let's hurry to make up for our shortcomings. Let's share with you the wrong problem set of mobile phone in the process of practicing Java foundation.
In Java programming, the java compiler converts a java program to ()
- Bytecode
- Executable code
- Machine code
- None of the above is true
Select A
- The compiler compiles Java source code into bytecode class files
- After the class is loaded into the JVM, the execution engine converts the bytecode into executable code
- The executable code is converted into machine code and executed by the underlying operating system.
The following Java programs run as a result:
Copy code
public class Tester{ public static void main(String[] args){ Integer var1=new Integer(1); Integer var2=var1; doSomething(var2); System.out.print(var1.intValue()); System.out.print(var1==var2); } public static void doSomething(Integer integer){ integer=new Integer(2); } }
In java, the transfer of an argument of a reference type to a formal parameter is only a passed reference, not the passed object itself.
Draw your own picture, and there is no visio! Draw pictures directly!

What is the result of the execution of the following code ()?
public class Demo{ public static void main(String[] args){ System.out.print(getNumber(0)); System.out.print(getNumber(1)); System.out.print(getNumber(2)); System.out.print(getNumber(4)); } public static int getNumber(int num){ try{ int result = 2 / num; return result; }catch (Exception exception){ return 0; }finally{ if(num == 0){ return -1; } if(num == 1){ return 1; } } } }
Rules:
1.try block is required. Both catch block and finally block are optional, but one or both must exist. try blocks cannot exist alone.
2. If an exception occurs during the operation of the statements in the try block, other statements in the try block will be skipped and the statements in catch will be run directly.
3. No matter whether there is an exception in the try block or whether the statement in the catch block is implemented, the statement in the finally block will be executed.
4. If there is a return statement in the try block or catch block, the statement in the finally block will be executed before the return statement in the try block or catch block.
5. If there is a return statement in the finally block, it will be returned directly without executing the return statement in the try block or catch block.
6. There is only one way not to execute the statements in the finally block, that is to call system exit(1); Method to exit the java virtual machine.
Emphasis: the statements in the finally block are executed before the return in try or catch!!!
The following statement about the life cycle of servlets is incorrect?
Creating your own Servlet When, you should initialize the method init()Method Servlet example
stay Servlet Service phase of life cycle, execution service()Method according to the method requested by the user doGet()or doPost()method
In the destruction phase, execute destroy()Method is released Servlet Occupied resources
destroy()Method is executed only once, that is, when the server is stopped and uninstalled Servlet Execute this method when
The life cycle of Servlet is divided into five stages: loading, creating, initializing, processing customer requests and unloading.
(1) Load: the container loads the servlet using the file corresponding to the servlet class through the class loader
(2) Create: create a servlet object by calling the servlet constructor
(3) Initialization: call init method to initialize
(4) Processing customer requests: whenever there is a customer request, the container creates a thread to process the customer request
(5) Unload: call the destroy method to let the servlet release its occupied resources
For the construction method, the following description is correct ().
Constructors generally have a lower priority than code blocks.
The return type of a constructor can only be void Type.
The main function of constructor is to complete the initialization of class objects.
Generally, when creating a new object, the system will automatically call the construction method.
A: Static member variable or static code block > main method > non static member variable or non static code block > construction method
B: It is mentioned in think in java that the constructor itself does not have any return value.
C: The main function of constructor is to complete the initialization of class objects.
D: Generally, when creating (new) new objects, the system will automatically call the construction method.
The output of the following program is
Copy code
public class Print{ static boolean out(char c){ System.out.println(c); return true; } public static void main(String[] argv){ int i = 0; for(out('A');out('B') && (i<2);out('C')){ i++; out('D'); } } }
Start of for loop execution
First, execute out('A ') to output A;
Then execute out ('b ') & & (I < 2) at this time, output B, i=0, judge the condition as true, and execute the loop body of the for loop;
Execute I + +, out('D '), and output D i=1;
Execute out('C ') and output C
Then execute out ('b ') & & (I < 2) at this time, output B, i=1, judge that the condition is true, and execute the loop body of the for loop;
Execute I + +, out('D '), and output D i=2;
Execute out('C ') and output C
Then execute out ('b ') & & (I < 2). At this time, output B, i=2. If it does not meet the judgment condition of I < 2, it is false, and jump out of the loop;
So the result is ABDCBDCB
OK, that's all for today