Basic Java Concepts

Source: Internet
Author: User
Tags define abstract

1. Java features and Benefits: simplicity, object-oriented, portability, high performance, distributed, polymorphic, multi-threading, security, robustness.

2, Java operating mechanism, high-level computer programming language types are: compiled, interpreted. The Java language is the combination of these two types, using the editor to write Java source program, and then the compiler compiles the source program into a class file, and then use the virtual machine (interpreter) to explain the execution, running process: loading, code validation, interpretation execution.

3. The Java Runtime Environment JRE contains: Java virtual machines, number of libraries, files required to run Java applications and applets.

The development environment JDK (also known as SDK) contains: JRE superset, compiler, debugger, etc. open anticipation tools.

4. Three main functions of Java running Environment: loading code: Completed by class loader; code validation: completed by bytecode verifier; execution code: run by Runtime interpreter. 5, Java data types are divided into two categories, that is, the basic data types and reference data types, there are 3 types of basic data types 8 basic data types (logical type-boolean; text type-char; numeric-byte, short, int, long, float, double) , the reference data type has a class (class), an interface (interface), an array, and note that the size of the reference data type is 4 bytes, and the address of the reference object is recorded. Byte type (1 bytes), short (2 bytes), int (4 bytes), Long (8 bytes), Float (4 bytes), double (8 bytes). 6, &&: The result of the & operation is the same, but the operation process is a little different. &: No matter what the results on the left are, the right side is involved in the operation; &&: When the left is false, the right side does not participate in the operation. The results of the operation are the same, but the operation is a little different. |: Regardless of the result on the left, the right side participates in the operation. : When the left is true, the right side does not participate in the operation.7, XOR or operation, when a number of different or operation the same number two times, the result is the number itself, such as A^b^b=a8, Stack memory: The stored is a local variable, and the scope of the variable belongs to the end, the variable is automatically released.     Heap Memory: Storage is an array and an object (in fact an array is an object) all new is in the heap. Features: Each entity has an initial address value. Each variable in the heap memory has a default initialization value, which differs depending on the type. The integer is 0, decimal 0.0, or 0.0f,boolean false char ' \u0000 '. As a result, local variables must be initialized, while global variables may not initialize existing default values. 9. Two common exceptions to array arrays: the definition of subscript bounds and Null pointer exception arrays: Arrays are collections of the same type of data, which describes the combination of several data of the same type, each of which is called an array element, and each array element can be accessed by a subscript. Four basic features of the array: 1. Fixed length, once created its length is not to be changed; 2. The element type must be the same type, no blending type is allowed; The elements in the array can be any data type, including the base data type and the reference data type; 4. Array variables are reference types, and arrays can be seen as objects, arrays of Each element is equivalent to the member variable of the object, the array itself is the object, and the object in Java is in the heap, so the array itself is in the heap, regardless of whether it holds the original type or other object types. 10. The difference between a member variable and a local variable: the member variable is defined in the class and can be accessed throughout the class. A local variable is defined in a function, statement, local code block, only valid in the area to which it belongs. Member variables exist in the object of the heap memory. Local variables exist in the method of stack memory. The member variable exists as the object is created and disappears as the object disappears. Local variables exist with the execution of the owning region and are released as the end of the owning region. Member variables have default initialization values. Local variables do not have default initialization values. 11. Form the function constructor: The function that is called when the creation object is constructed. Role:objects can be initialized, and object creation must be initialized through constructors. If a constructor is not defined in a class, there is a default null argument constructor in the class. If the specified constructor is defined in a class, the default constructor in the class is gone. What is the difference between a general function and a constructor: When an object is created, the corresponding constructor is called, and the object is initialized and called only once. General functions: After an object is created, it is called when function functions are required and can be called multiple times. When does the constructor function be defined?Some of the things that exist when describing things, which are defined in constructors. Constructors can have multiple, targeted initialization of different objects. Multiple constructors are represented in a class in the form of overloading.12.Static code block:executes as the class loads. and executes only once. Function: Used to initialize a class.  13.Static characteristics: Static is a modifier that is used to decorate a member. The members of the static modifier are shared by all objects. Static takes precedence over the existence of an object because static members already exist as the class is loaded. The members of the static modifier are called in a way that can be called directly by the class name. The class name. Static members. The static decorated data is shared data, and the data stored in the object is unique. 14. The difference between a member variable and a static variable the life cycle of the two variables is different: the member variable exists as the object is created and released as the object is recycled. Static variables exist as the class loads, disappearing as the class disappears. Called differently: Member variables can only be called by an object. A static variable can be called by an object and can also be called by a class name. Aliases are different: member variables are also known as instance variables. A static variable is called a class variable. Data storage location is different: the member variable data is stored in the object of the heap memory, so it is also called the object's unique data. Static variable data is stored in the static area of the method area (shared data area), so also called the object's shared data 15, static usage considerations: Static methods can only access static members. The this or Super keyword is not available in static methods (static and non-static) that can be accessed statically or statically.The main function is static. 16.Abstract class Characteristics: The method is only the declaration is not implemented, the method is an abstract method, need to be abstract modified. Abstract methods must be defined in an abstract class. The class must also be modified by the abstract. Abstract classes cannot be instantiated. Why? Because it doesn't make sense to invoke an abstract method. An abstract class must have its subclasses overwrite all of the abstract methods before the subclass can be instantiated. Otherwise, this subclass is an abstract class. There are constructors in the abstract class that are used to initialize the child class object. Abstract classes can not define abstract methods, but are rare. The goal is to not let the class create objects. The adapter object for AWT is this class. Abstract keywords cannot coexist with these keywords? The similarities and differences between private, static, final abstract classes, and general classes: the same: Abstract classes and general classes are used to describe things, all of which have members within them. Different points: The General class has enough information to describe things. Abstract classes may not have enough information to describe things. Abstract methods cannot be defined in a generic class, only non-abstract methods can be determined. Abstract methods can be defined in abstract classes, and non-abstract methods can also be defined. A generic class can be instantiated. Abstract classes cannot be instantiated. An abstract class must be a parent class, because subclasses are required to overwrite their methods before they can be instantiated on a child class. 17. Inheritance and construction of the instantiation of a Taipa subclass: All constructors in a subclass access the constructor of the null argument in the parent class by default. Why do you want to access the constructor in the parent class when the subclass is instantiated? That's because the subclass inherits the parent class and gets the contents (attributes) in the parent class, so before you use the parent class content, you first see how the parent class initializes its own content. So when a subclass constructs an object, it must access the constructor in the parent class.Note: The Supre statement must be defined in the first row of the subclass constructor. Because the initialization of the parent class is done first. 18.Final keyword final is a modifier that can be decorated with classes, methods, and variables. The final decorated class cannot be inherited. The final modified method cannot be overridden. The final modified variable is a constant and can only be assigned once. Why use final modifier variables. In fact, in the program if a data is fixed, then the direct use of this data can be, but so poor reading, so it is the name of the data. And the value of this variable name cannot be changed, so add final fixed. 19. The similarities and differences between abstract classes and interfaces are the same points: they are drawn from each other continuously. Different points: Abstract classes need to be inherited and can only be inherited. Interfaces need to be implemented and can be implemented more. Abstract methods and non-abstract methods can be defined in a class, and after the subclass inherits, non-abstract methods can be used directly. Only abstract methods can be defined in an interface and must be implemented by subclasses. 20. An Object instantiation process
New Person ();
The JVM reads the Person.class file under the specified path into memory and loads the parent class of the person (if there is a direct parent class). Space in heap memory, assigning addresses. And in object space, the properties in the object are initialized by default.invokes the corresponding constructor for initialization. In the constructor, the first row is initialized by calling the constructor in the parent class first. After the parent class is initialized, the properties of the child class are displayed for initialization. The specific initialization of the subclass constructor. When the initialization is complete, assign the address value to the reference variable.

Basic Java Concepts

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: [email protected] 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.