1. Will a float or double type be rounded when it is converted to an integral type?
Answer: No, when you convert a float or double type to an integral type, the fractional part is always chopped off
2. If you have defined a construction method (with or without parameters), does the compiler also create a default constructor method?
Answer: If there is no constructor in the class, the compiler will automatically create a default constructor method (no parameter constructor method) and the compiler will not create the default constructor method if the constructor is already defined (with or without parameters).
3. The This keyword can be used outside the method?
Answer: The This keyword can only be used inside a method, meaning a reference to the object that called the method, which represents a reference to the current object.
4. The garbage collector in Java can only release memory that has new allocations, right?
Answer: The garbage collector in Java can only release memory that has new allocations, assuming that your object obtains a block of "special" memory areas that are not allocated by new, and that the garbage collector does not know how to release this "special" Memory of the object, in order to cope with this situation, Java allows you to define a method named Finalize () in a class. It works "should" be like this: once the garbage collector is ready to release the storage space occupied by the object, its finalize () method will be called first, and the object will actually reclaim the memory when the next garbage collection action occurs.
5. Is it possible to assign a value to a final modified variable if the variable is not initialized when it is defined?
Answer: Yes, with the final modified variable, if the variable is not initialized at the time of definition, it can only be assigned in the constructor method, and once the value is assigned it cannot be changed again, and the final modified variable has no default value.
Five basic questions in Java easy to get back to the veteran