2018 Java Face Test Finishing (1)--Basic __java

Source: Internet
Author: User

Recently, individuals are also preparing for a job search. I organized a number of Java face questions for your reference, we work together to find a good job! If you have some basic questions, you can comment to me. I'll do the sorting. Thank you for sharing. Follow-up will provide a relatively rare face test.

What are the three main features of Java object-oriented features are encapsulation, inheritance, and polymorphism. (ask these questions to try to answer their meanings.)

Encapsulation refers to the packaging of attributes and behavior of something to an object, which only publishes attributes and behaviors that need to be disclosed, and this publication can be selectively advertised to other objects. In Java, you can use private, protected, public three modifiers, or no (that is, the default defalut) to restrict the properties and behavior of an external object to access that object. (Here's another problem:java modifier scope ) inheritance is the property and behavior that a child object can inherit from a parent object, that is, the properties and behavior that the parent object has, and its child objects have these properties and behaviors.    This is very similar to the genetic nature of the species. Three necessary conditions for polymorphic existence:
First, to have inheritance;
Second, to have to rewrite;
Third, the parent class reference points to the child class object.

  polymorphism means that the same behavior in a parent object can have a different representation in its multiple child objects . That is, a child object can use an overriding behavior in the parent object to have a different representation from the parent object and other child objects, which is overriding (Overrides).      polymorphism is embodied in overriding (Overrides), while overload (overloading) is not part of the object-oriented polymorphism, because the overload (overload) concept also exists in non-object-oriented contexts. overriding (Overrides) and overload (overloaded) The overlay overriding and overload overloading of the method are different manifestations of Java polymorphism; overlay overriding is a manifestation of polymorphism between parent class and subclass, and overload overloading is an expression of polymorphism in a class. What is the difference between
error and exception? error indicates system-level errors and exceptions that the program does not have to deal with, which is a serious problem in situations where recovery is not impossible but difficult; for example, memory overflow, It is impossible to expect a program to handle such a situation; exception represents an exception that needs to be captured or required to be handled by a program, which is a design or implementation problem; Does the
interface inherit interfaces? Can an abstract class implement a (implements) interface? Whether an abstract class can inherit an entity class an interface can inherit an interface. Abstract classes can implement (implements) interfaces, and abstract classes can inherit entity classes, provided that an entity class must have an explicit constructor. The
Java ArrayList and LinkedList difference 1.ArrayList implements a data structure based on dynamic arrays, LinkedList based on the data structure of a linked list.  
2. For random access get and set,arraylist feel better than LinkedList because LinkedList want to move the pointer.  
3. Add and Remove,linedlist are more advantageous for new and delete operations because ArrayList want to move the data.  
ArrayList and LinkedList default space is how many

The ArrayList initialization size is 10 (if you know how much capacity your ArrayList will achieve, you can specify it at initialization time to save on performance expenses for expansion) LinkedList is a two-way list with no initialization size and no expansion mechanism, Just keep it up front or back.
difference between static and instance variables static variables are variables decorated with the static modifier, also known as class variables, which belong to classes, are not part of any instance object of the class, a class no matter how many instance objects are created, static variables are in memory and only one copy Static variables can be implemented to allow multiple objects to share memory.

An instance variable must be dependent on an instance object, and the instance object needs to be created before it can be accessed through an instance object.
What is the difference between the sleep method and the wait method? The sleep method is a static method of the thread class that lets the calling thread go into hibernation while giving the execution an opportunity to the other thread, waiting until the end of the sleep time to get the thread into a ready state and preempt the CPU for an execution opportunity. However, if the current thread has a lock, Thread.Sleep does not let the thread release the lock.

The wait method is a method of the object class that, when a thread executes to the waiting method, enters an object-related pool of waits, releasing the lock of the object, allowing other threads to access it, and the waiting thread needs to be awakened through the Notify and Notifyall methods.
= = and equals the difference compares the basic data type, = = and equal effect, for reference object comparison, equals compares the value, = = compares the memory address.

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.