Java Interview 2

Source: Internet
Author: User

Wuyi , Java What is the mechanism to implement polymorphism in.
A : the overriding overriding and overloaded overloading of methods are different manifestations of Java polymorphism. Overriding overriding is a manifestation of polymorphism between parent classes and subclasses, and overload overloading is an expression of polymorphism in a class.

- , what is the basic principle of the garbage collector. Can the garbage collector reclaim memory immediately? What are the ways to actively notify virtual machines for garbage collection
A : for GC, when a programmer creates an object, the GC begins to monitor the address, size, and usage of the object. Generally, the GC uses a heap to record and manage all the objects in the heap (). In this way, determine which objects are "accessible" and which objects are "unreachable." When the GC determines that some objects are "unreachable," the GC is responsible for reclaiming the memory space. OK. The programmer can manually execute System.GC () to notify the GC to run, but the Java language specification does not guarantee that the GC will execute.
- , static variables, and instance variables.
Answer:static i = 10;  Constant Class A; A.I =10;//Variable

the , what is Java serialization, how to implement Java Serialization.
A : serialization is a mechanism for dealing with object flows, which means that the object flow is the flow of the object's contents. The objects that can be streamed are read and write, and the streaming objects can be transferred between the networks. Serialization is a solution to problems that arise when reading and writing to an object stream.
Serialization implementation: The Serializable interface that will need to be serialized implements the interface, which has no method to implement, implements serializable just to annotate that the object is serializable, and then use an output stream ( such as: FileOutputStream) to construct a ObjectOutputStream (object stream) object, and then use the writeobject of the ObjectOutputStream object. Object obj Method can write out (that is, save its state) an object whose parameter is obj, and then use the input stream to recover.

- , whether you can from a Static method internally emits a pair of non Static the invocation of the method.
A : No, if it contains the object's method (), the object initialization cannot be guaranteed.

A , write Clone () method, there is usually a line of code, what is.
Answer: Clone has the default behavior, Super.clone (); He is responsible for generating the correct size of space and copying it bits by bit.

by , in JAVA , how to jump out of the current multiple nested loops.
Answer: use break; Return method.

the , List , Map , Set three interfaces, when accessing elements, what are the characteristics of each.
Answer: The List holds elements in a particular order and can have duplicate elements. Set cannot have duplicate elements, internal sort. Map holds Key-value value, value can be multi-valued.

the , say some commonly used classes, packages, interfaces, please lift 5 a
A : commonly used classes: BufferedReader bufferedwriter filereader filewirter String Integer

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.