What are the common annotations in Java and what are the syntax?
: Single-line comment
/**/: Multiline Comment
/** */:doc Documentation Comments
Second, what are the common Java operators?
+ - * / %
Third, what are the basic data types of Java?
int: integer double: double char: Single character string: string
Float: Single precision Byte:short:long:
Iv. write out the syntax of the 3 if selection structure and the execution process
if () {}else{} basic if judgment
if () {}else if () {}else{} multiple if judgment
if () {
if () {
}else{
}
}else{
}//Nested IF structure
Please write the syntax of the switch selection structure and the execution process
The value of the switch (expression) {//Expression) is compared to the constant value after the case, the corresponding value is found, the output statement is executed, and if no default is found;
Case 1:
System. OUT.PRINTLN ();
Break
Case 1:
System. OUT.PRINTLN ();
Break
Default
System.out.println ();
Break
}
Six, please write while,do-while grammar and its characteristics
While: First judge the execution
Do-while: First execution, in judging
Please write out the syntax for the For loop, and execute the process
for (initial part; condition judgment; change loop variable value) {
Looping operations
}
The first initial value is judged, satisfies the condition to enter the loop body, does not satisfy jumps out
Each time you enter the loop, the initial value changes, knowing that the condition is not satisfied.
Please write out the basic syntax of the array. and basic elements
Declaring an array: the data type [] array name, or the data type array name [];
Int[] A=new int[5];
A[0]=1;
a[1]=2;
Simultaneous assignment of declarations: int[] a=new int[]{1,2,3};
The array is calculated starting from the 0 table,
Array has only one name, base identifier,
The size (length) of the array is the maximum number of elements the array can hold. If the subscript of an array exceeds this size, the program terminates with an error
Nine, how to sort ascending and descending array of groups? Please write your thoughts.
Ascending, Arrays.sort (array name);
Descending order: For loop backwards output, first output the maximum subscript, the length of the array-1, get the maximum subscript, each cycle-1. Conditional >0 until the conditional exit loop is met
How do I find the maximum and minimum values for an array? Please write your thoughts.
Declares two variables Max Max and Min min
The 0 subscript in the array is paid to the two variables, and the array is evaluated by the for loop, and if the value in the array is greater than Max, the value of the array is paid to Max
If the value in the array is less than min, the value of the array is paid to min
Xi. How do I insert an element into an array? Please write your thoughts.
& Declare a variable to store the subscript position first
Use the For loop to iterate over each item of the array, find the relative position, and the number of loops that is the array subscript
Assigns a variable to receive subscript, and then uses the reverse output of the For loop to move the element back, assigning the previous bit of the largest subscript to the maximum subscript.
Then empty subscript = Enter the inserted value.
The last loop outputs the array.
12. Double for loop syntax, and features
for (int i=0;i<3;i++) {
for (int j=0;j<2;j++) {
code block
}
}
Outer loop once, inner layer performs one lap
13. break; and continue; use and difference
break; to jump out of the current loop
Continue; end current loop, execute Next loop
14. Please write out the relationship between class and object
The relationship between the & class and the object is abstract and concrete.
Please write out the difference between a member variable and a local variable?
Member variables: Scopes are visible within the entire class, and all member methods are available.
The member variable is not assigned an initial value in the class, and Java gives him a default value of 0 for the base data type.
Local variable: scope is limited to the method that defines it and is inaccessible outside of the method. When a local variable is not assigned a value, the Java
The local variable is not paid the initial value, so the local variable must be assigned before it can be used.
16, how to define the properties and methods of the class? How do I use properties and methods in a class?
1. Defining the class name
public class class name {}
2. Writing properties in classes, and methods of classes
Syntax: public class class Name {
Type attribute 1;
Define Method Section
public void Method name () {
}
}
17. What are the uses of return?
& Returns a value to the current method
18. Would you describe the idea of object-oriented programming?
& OO Programming (Object Oriented Programming OOP) is a computer programming architecture that was popular in the the 1990s
A kind of software programming idea.
19. What problems should you pay attention to when calling the class's parameter method?
Data type consistent, number consistent, each corresponding
20. What is the method for writing string strings, and what is the purpose?
You can use the: IndexOf () method. Find the subscript position of a character
LastindexOf () method to find the subscript position of a string
subString (int index) method to extract string after the beginning of the string
subString (int beginindex,int endindex) method for intercepting strings
Trim () method to ignore spaces before and after a string
String. Split (Sting Separator,int limit) method, used to split a string
Separator with what parameters to divide,
Limit parameter, split into several lines
String. Insert () method; Insert character
Convert to String type
StringBuffer a = new StringBuffer ("ASD");
A.tostring ();
21, = = and equals what is the difference?
= = used for memory address comparison
equals is used to compare values for equality
22. How to use StringBuffer for string stitching, please write code?
StringBuffer s = new StringBuffer ("ASD");
S.append ("Zxc");
Use Java to understand the basic question of program logic?