Dark Horse programmer Java SE Review

Source: Internet
Author: User
Tags constant definition terminates multiple inheritance in java java se

----<a href= "http://www.itheima.com" target= "blank" >java training, Android training, iOS training,. NET training </a>, look forward to communicating with you! -------

Java SE Basics Review

1. Break in a looping statement terminates all loops, jumps out of the loop body, and continue terminates the loop, jumping to the next loop

The 2.return statement has two functions: return value; End method Run

3. For object-oriented understanding in Java: Organize the code as a class and encapsulate the data as an object. Classes are equivalent to templates, and objects are created from templates.

4. Local variables need to be initialized to be used, and the global variable system automatically initializes them. class = attribute + method
5.java Memory Analysis: (1) Stack: Store local variables (automatic allocation of continuous space, stamina first Out) (2) Heap: Prevent new objects (discontinuous) (3) Method area: (also heap) is the code information of the class, static variable, Chang (string constant)

The operation of an object in 6.java is actually an action on an object's address

7. Constructors are called construction methods whose names must be identical to the corresponding class names. Constructors can also be overloaded. Overloading has two three different principles, that is, the same class, the same method name; parameter list (type, number, order) is different

Only the names of the formal parameters are different and do not constitute overloads. The return value is different and does not constitute an overload

The 8.static keyword-decorated method is a static method, and calling a static method does not require the creation of an object, only the class name. The method name can be used to invoke the static method. Static properties and methods can be called in a normal method, but non-static properties cannot be called in a static method. This refers to the object that invokes the current method

The class in 9.Java has only single inheritance, and multiple inheritance in Java is implemented through interfaces.

10. There are 6 types of relationships between classes: inheritance, implementation, dependency, association, aggregation, composition

11. Inheritance: Generalization of the parent class maintenance commonality, refinement subclass add attribute

12. Dynamic binding: At run time, the JVM is able to bind specific methods based on the type of object.

13. Dynamic method Scheduling: If you want to implement dynamic binding in a programming language, you must have a mechanism to be able to determine the type of the object and call the appropriate method, which is called dynamic method scheduling. Dynamic method Scheduling is the basis for implementing Java Runtime polymorphism

The 14.equals () method compares whether the contents of the object referenced by the two variables are the same; = = "The comparison is whether two variables refer to the same object, focusing on whether the space is the same, that is, two objects in memory address

15. About string content: When you define a string type variable by means of a string constant definition (that is, string s= "ABCD"), the system first looks for the same string object from the string pool (the JVM maintains a string buffer called a string pool). If you find the variable to point to an existing object in the pool, create a new object and put it in the pool. So string variables, defined by string constants, must point to the same object if the content is the same. That is, string s= "ABCD"; String m= "ABCD"; they point to the same object, but if a string object defined with new string ("ABCD") is not placed in the pool, the new object is reconstructed each time.

16. Abstract class: Define only the "skeleton" of the class, provide a specification for its common behavior, but do not implement, but put the concrete implementation into the subclass to complete. This "skeleton class" is called an abstract class, decorated with the abstract keyword

17.3 Characteristics of abstract class: (1) Abstract method has no method body, that is, is not implemented (abstract before class, an abstract class can contain multiple abstract methods, can also contain implemented methods)

(2) You cannot instantiate an abstract class, that is, you cannot assign a specific space to an abstract class (3) When a class inherits an abstract class, the class must also be defined as an abstract class if it does not implement all of the abstract methods of the parent class.

18. Interface: The introduction of interfaces is to solve the problem of single inheritance between classes. Interface is the further hardening of abstract class, there is no method body, cannot be instantiated directly. A reference to an interface is equivalent to the parent class of an interface that invokes a method of a subclass, that is, a parent class reference to a subclass object. A class can implement multiple interfaces to compensate for a single Java inheritance flaw. When a class implements an interface, it is compulsory to implement all of the methods defined by the interface, unless the class is defined as an abstract class.

19. Inner classes are: member inner class, local inner class, Static inner class, Anonymous inner class

Anomalies in 20.java are divided into: Java.lang.error and Java.lang.Exception

An exception is an error that may occur during a program's operation. Exceptions are classified as non-checked exceptions (RuntimeException and their subclasses), check-type exceptions

21. Exception Handling mechanism: (1) Catch exception (2) declaration throws exception

22. When arranging the order of the catch statements, first catch the most special exception, and then in generalization, catch the subclass first, and then in the Catch parent class. The order does not match, the error will occur

Whether or not an exception occurs, the code finally keyword that must be executed is decorated, and finally cannot be used alone, and must be used in conjunction with try. Try-finally, try-catch-finally

The 23.throw statement is written in the method, and the throws statement is used after the method signature. In the same method, throws throws a range of types that are larger or identical than the object type thrown by the throw

24. Generics: is to resolve coercion type conversions, the compiler may not prompt for errors at compile time, but there will be exceptions at run time, which is a security risk.

25. Benefits of using generics: (1) Checking for types during compilation, catching Type mismatch errors (2) All casts are automatic and implicit, increasing code reuse rates.

26. The nature of generics: is a parameterized type, that is, the operation of the data type is specified as a parameter, can be used in the creation of classes, interfaces, methods.

27. Array container (must learn key when encountering container)

Format 1 int[] array = new int[3];//requires a container, but does not explicitly specify the container's specific data

Format 2 int[] array = new int[]{0,1,3,5,89};//initializes the container, stores the known data or int[] array = {89,20,2,45,9};

For the operation of arrays, the most basic is to save and fetch. The core idea is: the operation of the diagonal mark, the last number of the array in the corner marked as Array.length-1

28. Object oriented: First find the object of the problem, if not, to create it. Objects are found, objects are not created, and relationships between objects are maintained. The relationship between a class and an object: A class is a description of a thing. Object: An instance of this class, implemented in Java through new. The data is encapsulated in the heap, and objects are also encapsulated for data. When the method is called, the method is to be in the stack, if local variables such as a=10 are defined in the method, a=4 are also defined in the heap, the local variables in the stack are preferred, and a=4 is called in the heap if there is no a=10 in the stack.

29. When an object makes only one call to a method, it can be simplified to an anonymous object

30. Encapsulation: Encapsulation the properties and implementation details of hidden objects, providing public access only to the outside. Proprietary private things can only work in this class. To logically contract a given data in a method (the role of encapsulation)

31. Constructor: The function that is called when building an object: The object can be initialized. The creation of an object must be initialized with a constructor.

32. The difference between a general function and a constructor: the constructor: When the object is created, it calls its corresponding constructor to initialize the object. is called and is called only once (for an object only)

General functions: When an object is created, it is called when a function function is required. After an object is created, it can be called multiple times.

33. When to define a constructor: some of the things that exist when a thing is described is defined in the constructor.

You can have more than one constructor in a class that initializes different objects differently. Multiple constructors appear in the same class, only one way-overloading

Dark Horse programmer Java SE Review

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.