Java short answer

Java short answer

Please indicate the source

1. The relationship between classes and objects

Class is a template configuration object, the object is a specific instance of a class. It describes a class have the same set of properties (attributes) and the object with the same behavior (method).

2. What are the advantages of object-oriented programming is that?

1) Data abstract concept can be changed while keeping constant internal implementation external interface, so as to reduce or even avoid the interference from the outside world;
2) by extending substantially reduce redundant code, and can easily be extended existing code, to improve the coding efficiency, but also reduces the probability of errors and reduce the difficulty of software maintenance;
3) combined with object-oriented analysis, object-oriented design, allows mapping of the problem domain objects directly into the program, reducing software development process in the middle part of the conversion process;
4) by discrimination of the object, can be divided into software system is divided into a number of relatively independent part, easier control software complexity to a certain extent;
5) in object-centric design can help developers static (properties) and dynamic (method) grasp both issues, and thus achieve better system;
6) by polymerization of an object, can be combined in the package and ensure the realization of the object abstract principles inner and outer extents on the function of the structure, in order to achieve target upgrade from low to high.

3. Why do you want to define static methods, static methods are characterized by what?

Because static methods are not required to instantiate, as long as through the class name method name can be called.
Features: No need to declare an object can be called.
Which can not be access class instance variables.

Why 4.java to introduce the package, the package between access control feature is what? (Expressed in the form of a table)

In order to better organize the class, Java provides a package mechanism for the namespace distinguish class names, making the program features clear, clear structure. Packages may also be implemented between different programs reusable classes.

Table 1 access control levels

Access range private default protected public
The same class
In the same packaging
Subclass
Global scope

What are the characteristics and the presence of major significance 5. The abstract class is?

Features: Representative abstraction, no specific examples of the object
before the need to add modifier abstract class
may contain anything that can contain conventional type of construction method e.g., non-abstract methods
may include an abstract method
a non-abstract class that inherits the abstract class, an abstract class must be the abstract method overrides, implementation, rewriting
meaning:
to allow other classes to inherit its abstract features
common behavior includes a subclass of shared property
can not create an object, to ensure the safety of the code, in favor of the code maintenance and reuse

What are the characteristics and the presence of major significance 6. The end of the class is?

Features: The End of the class can not be inherited (can not have derived classes)
is modified final modifier class
meaning:
1) to prevent subclasses override the wrong key on the parent class method, increasing the security code
2) improve operational efficiency

7. What is generic, what is the main purpose of the introduction of generics?

Generic nature of the parameter type, i.e., the data type of the operation is specified as a parameter.
The Java language has become more simple, safe, in the case of the use of generics, the compiler will check for safety, and all type conversion is automatic and implicit, can increase code reuse.

8. What are the characteristics of the interface and the presence of major significance is?

Features:
1) Interface allows you to define a common behavior among objects irrelevant
2) interface data members must be given initial value, and this value will not be changed, allows you to omit the final keyword
method) interface 3 must be " abstract method ", there are not a method thereof, allowing public abstract keyword is omitted and
4) the interface can not be generated directly by the new operator object, you must use its characteristic design of new classes, then the object class to create a new
5) must implement the interface All methods, methods from the interface must be declared public
significance:
1) object-oriented is an important mechanism
2) realization of java in multiple inheritance, eliminating the in C ++ multiple inheritance complexity
3) establish classes and between "agreement": the class to represent function according to its implementation, without having to worry about it in the class inheritance hierarchy, so you can maximize the use of dynamic binding, hiding implementation details
4) to achieve constant sharing between different classes

Why 9.java to be introduced multi-state mechanism?

1) all of the objects may be the same type of plastic, the same response message
2) makes the code becomes simple and easy to understand
3) so that the program has a good "scalability"

10. What is Java abnormal, what is the purpose of introducing an exception?

In the execution of the program, any abnormal conditions interrupt the normal program flow is abnormal.
The purpose of introducing anomalies:
1) resolve errors during operation
2) can prevent unexpected error code or system error caused by the result of the occurrence of
flexibility 3) increase the program's readability and robustness

Published 43 original articles · won praise 30 · views 5975

Guess you like

Origin blog.csdn.net/qq_42049496/article/details/89184587