1. How are the lengths of arrays, strings, and collections obtained?
Array name. Length; property
String. Length (); method
Collection. Size (); method
2. What are the characteristics of arrays?
1. is a continuous memory space, subscript starting from 0, the maximum subscript is the length-1;
2. Each element is a variable;
3. The type of the element and the type of the definition array are identical;
4. By the length property to get the size of the array, once the built length of the array cannot be changed;
5. After the array is built, each element is initialized; int----0 Double----0.0 reference type-----NULL
3. What are the key words for inheritance? Subclass inherits the parent class, how should the first sentence of the construction method be written?
Following the keyword extends
Subclass inherits the parent class, constructs the method the first sentence: Super ();
Calls the parent class's construction method to produce the parent class object;
4. What is the difference between rewriting and overloading? What are the requirements for rewriting?
Overloads occur in the same class, with the same method name, with different parameter lists (parameter type, number of arguments, parameter order), and regardless of the return type, the virtual machine determines which overloaded method to invoke based on the contents of the argument;
Overrides occur between the parent class and the child class, with the same overriding method name and the same return type for the parameter list;
The access modifier must be greater than or equal to the modifier of the parent class, and the method that the subclass overrides is called when the method is called;
Throws an exception that is less than or equal to the exception thrown by the parent class;
5. Can a class in Java inherit multiple classes at the same time? What is the parent class for all classes?
No, a class in Java can inherit only one parent class;
The parent class of all classes is Object
Java Fundamentals 5