Java Key Knowledge Point collection

Source: Internet
Author: User

What is the serialization of Java

is to save an object to a file, can be transferred through the stream, you can read the contents of the file into an object, serialization is to solve the object flow in the time of the read and write operations caused by the problem,

Object flow is the flow of objects, the flow of objects can be transferred between the network, can be streamed to read and write operations of the object.

can I include more than one class in a ". Java" source file? What's the limit?

Is a Java file can write multiple classes, but there is only one public decorated class, as follows

1234567 publicclass A {}class B {}classC {}// 等等任意多个类,但是只有一个public class
What are the characteristics of the final class: the class can no longer be inherited, the constants can no longer be changed to inherit the time when the parent constructor is always called First 1, serialization is what?
This is simply to preserve the state of various objects in memory (i.e., instance variables, not methods), and to read the saved object state again. Although you can save object states in a variety of ways, Java provides you with a mechanism that should be better than your own to preserve the state of objects, which is serialization.


2. What situations require serialization
A) When you want to save the state of an object in memory in a file or in a database;
b) When you want to use sockets to transfer objects on the network;
c) When you want to transfer objects through RMI; print the day before

public void Date () {
Calendar calendar=calendar.getinstance ();
Calendar.add (Calendar.date,-1);
System.out.println (Calendar.gettime ());
}

Winson_ Zhang Lin says:
The biggest difference is in memory.
The static method generates memory at the beginning of the program, and the instance method generates memory in the program run.
So the static method can be called directly, the instance method must first genetic instance, through the instance calls the method, the static speed is very fast, but many will occupy the memory.
Any language is the operation of memory and disk, as to whether object-oriented, only the software layer of the problem, the bottom is the same, but the implementation method is different.
Static memory is continuous, because it is generated at the beginning of the program, and the instance is requesting a discrete space, so of course there is no static method fast,
and static memory is limited, too many programs will not start.

The difference between an abstract class and an interface:

Interface can be multiple inheritance, implements abstract class can only be single inheritance, extends, interface only definition, abstract class only definition and implementation, interface default field is public static final, abstract class is this package is visible.

When the function requires the class product to use abstract classes, when the function does not need to accumulate when the interface.

Java Key Knowledge Point collection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.