1:java Advantages of single root inheritance?
Convenient garbage collection: The design of garbage collection is easy to implement.
The problem of multiple inherited function names.
2: Downward transformation and upward transformation?
A downward transition is unsafe, and security is transformed upward.
3:SYSTEM.GC ()?
Just remind the JVM to do garbage disposal. There is no guarantee that it will be done.
4:arraylist VS LinkedList?
5:java Basic type size? What are the corresponding packaging classes useful?
Boolean (Unspecified) char (2) byte (1) short (2) int (4) long (8) Float (4) Double (8): Each base type has a corresponding wrapper class.
Packing class use:
As the class type corresponding to the basic data type exists, it is convenient to manipulate the object;
Contains relevant properties for each basic data type, such as maximum value, minimum value, and related operation methods;
|
Basic data types |
Packing class |
|
Byte |
Byte |
|
Boolean |
Boolean |
|
Short |
Short |
|
Char |
Character |
|
Int |
Integer |
|
Long |
Long |
|
Float |
Float |
|
Double |
Double |
6:java Heap and Stack?
A: The variable declared in the method, that is, the variable is a local variable, each time the program calls the method, the system will establish a method stack for the method, the variables declared in the method is placed in the method stack, when the method end system will release the method stack, corresponding to the method declaration of the variable with the destruction of the stack end, This is why local variables can only be valid in a method
A variable declared in a method can be a variable of a primitive type, or a variable of a reference type.
(1) When the declaration is a basic type of variable, its variable name and value (variable name and value are two concepts) are placed in the Java Virtual machine stack
(2) When a reference variable is declared, the declared variable (which is actually stored in the method as a memory address value) is placed in the stack of the Java Virtual machine, and the object to which it points is placed in the heap class store.
Two: A variable declared in a class is a member variable, also called a global variable, placed in the heap (because the global variable is not destroyed with the end of a method execution).
A variable declared in a class can be a variable of a primitive type and a variable of a reference type.
(1) When declaring a variable of the base type whose variable name and its value are placed in heap memory
(2) When referencing a type, the variable it declares will still store a memory address value that points to the referenced object. Reference variable names and corresponding objects are still stored in the appropriate heap
7: Turn the string "12" into a 16 binary number?
int a = Integer.parseint ("12", 16);
8: Integer to String?
String A1 = integer.tostring (5); Other types can go to string
String A2 = string.valueof (5); The string itself also has functions that can turn other types into string
9: Floating-point numbers in the calculation of high precision requirements?
Floating-point values are not suitable for financial calculations that prohibit rounding errors. For example System.out.println (2.0-1.1); will print 0.899999999999999 instead of 0.9. Because the floating-point value is represented by a binary system, the binary does not accurately represent a fraction of 1/10, just as a decimal does not accurately represent 1/3. You should use the BigDecimal class and the BigInteger if you need to have no rounding errors in the numerical calculations.
BigDecimal class: Fixed-point number that supports any precision.
BigInteger class: An integer that supports any precision.
10: When float, double to int, is the truncated operation, if you want to round, use the Java.lang.Math.round (5.8) method
int a3 = (int) Java.lang.Math.round (5.8);
11: Data Promotion:
If you perform an arithmetic operation on the base data type, the bitwise operation of the goods, as long as the type is smaller than int (char,byte,short), is automatically converted to int before the operation. If you want to turn the results into smaller types, you must use type conversions. The largest type in a typical operation determines the type of the result.
What type of 12:switch?
int, char, enum, String
13: Initialization of the class of the shaking data member?
Static members are initialized only once, when an instance of the class is first generated, or when a static member of the class is first accessed, the static is initialized first, and then the non-static
14: How does a subclass call the parent class constructor?
Super (X)
@override The role of annotations?
To overwrite a function in a subclass, add this annotation, and the compiler will prompt for an error when it is accidentally overloaded.
16:final usage?
When a reference is decorated, it indicates that the reference is always pointed, but the object pointed to can vary.
Final list<string > new arraylist<string>(); List.add ("AFA"); Correct new linkedlist<string> (); Error
Final person p1 = new person (A2, a);
P1.setage (5); That's right
Final String s= "FSDF";
s = "FSDFSDFSDFDSF"; Error because string is an immutable object, the re-assignment causes new objects to be changed, and final conflicts.
Final can be blank and initialized when the constructor is constructed.
When you modify a function parameter, you cannot change the object that the parameter reference points to ( you can change the value of the object, but you cannot re-point to another object ).
Final method: Prevents inheritance.
All private methods in a class are implicitly specified as final.
Final class: Cannot have child classes (cannot be inherited)
17: Abstract class characteristics?
Abstract class can have no abstract method, abstract method has no function body, subclass must implement, if not implement, subclass is abstract class; Abstract class cannot be instantiated;
18: Properties in interface?
The attribute is not generally defined if the defined property is static final in the interface.
19: The method in the interface is public, the default is public, and the function of the class that implements the interface is public.
20: Abstract columns and interfaces are all designed to achieve polymorphism, upward transformation, and decoupling.
JAVA Programming thought two