Java: Core Concept J Accumulation (i)

Source: Internet
Author: User

1. Abstraction

Abstraction is about ignoring aspects of a topic that are not related to the current goal, so that you can more fully focus on the aspects that are relevant to the current goal. Abstractions do not intend to understand all of the problems, but simply select one part of them, temporarily without some detail. Abstract includes two aspects, one is the process abstraction, the other is the data abstraction.

(subject, current target, selection part, process abstraction, data abstraction)

2. inheritance

Inheritance is a hierarchical model of a junction class and allows and encourages the reuse of classes, which provides a way to articulate commonalities. A new class of objects can be derived from existing classes, a process known as class inheritance. The new class inherits the attributes of the original class, which is called the derived class (subclass) of the original class, and the original class is called the base class of the new class (The parent Class). Derived classes can inherit methods and instance variables from their base classes, and classes can modify or add new methods to make them more suitable for special needs.

(Joins, hierarchies, class reuse, methods that represent commonalities; a new class of objects can be derived from existing classes, subclass derived classes, parent class base classes)

3. Encapsulation

Encapsulation is the process and data is surrounded, access to data only through the defined interface. Object-oriented computing begins with this basic concept that the real world can be portrayed as a series of fully autonomous, encapsulated objects that access other objects through a protected interface.

(Process and data, data access through a defined interface, object-oriented, access to other objects through a protected interface)

What is an interface? How to protect?

4. polymorphism

Polymorphism refers to allowing objects of different classes to respond to the same message. Polymorphism consists of parameterized polymorphism and inclusion polymorphism. Polymorphism language has the advantage of flexibility, abstraction, behavior sharing and code sharing, which solves the problem of application function with the same name.

(Non-homogeneous objects respond to the same message, parameter polymorphism, including polymorphism, application function name)

5. is string the most basic type?

> Basic data types include byte, int, char, long, float, double, Boolean, and short.

The >java.lang.string class is of the final type, so you cannot inherit the class or modify the class. To improve efficiency and save space, we should use the StringBuffer class.

(Final class, non-inheritable, non-modifiable)

What are the final class features? How to use it?

6. What is the difference between int and integer

Java offers two different types: reference types and primitive types (or built-in types). int is the raw data type of Java, and integer is the wrapper class provided by Java for Int. Java provides a wrapper class for each primitive type.

Raw type Encapsulation class

Boolean Boolean

Char Character

BYTE byte

Short Short

int Integer

Long Long

float float

Double Double

The behavior of reference types and primitive types is completely different, and they have different semantics. Reference types and primitive types have different characteristics and usages, including: size and speed issues, which types of data structures are stored as the default values that are specified when reference types and primitive types are used as instance data for a class. The default value of an object reference instance variable is NULL, and the default value of the original type instance variable is related to their type.

(Reference type, primitive type, behavior, semantics; characteristics, usage: size, data structure, default value)

What does semantics mean? Code embodies?

7. string and StringBuffer

The Java platform provides two classes: string and StringBuffer, which can store and manipulate strings, which are character data that contain multiple characters. This string class provides a string of values that cannot be changed. The string provided by this StringBuffer class is modified. You can use StringBuffer when you know that character data is going to change. Typically, you can use Stringbuffers to dynamically construct character data.

(Store and manipulate strings, variable, immutable, dynamically constructs character data)

Examples of string and StringBuffer code applications?

8. What is the difference between a run-time exception and a general exception?

An exception represents an unhealthy state that may occur during a program's run, and a run-time exception that represents an exception that may be encountered in a typical operation of a virtual machine is a common run error. The Java compiler requires the method to declare a non-runtime exception that might occur, but does not require that a runtime exception that is not caught to be thrown must be declared.

(Virtual machine operation exception, run error, compiler throws non-runtime exception)

9. Say the servlet's life cycle and tell the difference between a servlet and a CGI

After the >servlet is instantiated by the server, the container runs its Init method, the service method is run when the request arrives, the service method automatically dispatches the Doxxx method (Doget,dopost) corresponding to the request, etc. The Destroy method is called when the server decides to destroy the instance.

(Server instantiation servlet-init-request arrives service-doget/dopost-destroy destroy)

The difference between > and CGI is that the servlet is in a server process, it runs its service methods in a multithreaded manner, an instance can serve multiple requests, and its instances are generally not destroyed, and CGI generates a new process for each request, which is destroyed after the service is completed. So the efficiency is lower than the servlet.

(servlet: Server process, multithreaded run service, one instance service multiple requests, not normally destroyed)

(CGI: A request for a process, after the service is destroyed)

Describe the storage performance and features of Arraylist,vector,linklist

Both ArrayList and vectors store data using arrays , which are larger than the actual stored data in order to increment and insert elements, both allowing the element to be indexed directly by ordinal , but inserting an element In order to deal with memory operations such as array element movement, the index data is fast and the insertion data is slow, vector because of the use of the Synchronized method (thread-safe), usually performance is worse than ArrayList, and LinkedList using a doubly linked list for storage, Indexing data by ordinal requires a forward or backward traversal , but inserting data requires only the front and back of the item to be recorded, so the insertion is faster.

(ArrayList and vector arrays, fast indexing, slow insertion; LinkedList use doubly linked list, index slow insert fast)

Java: Core Concept J Accumulation (i)

Related Article

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.