|
Briefly describe the characteristics of encapsulation, inheritance, and polymorphism. 1。 Encapsulation: It is to encapsulate objective things into abstract classes, and classes can only operate their own data and methods to trusted classes or objects, and hide information from untrustworthy ones. Encapsulation is one of the characteristics of the class, which should be well understood, like some private, other classes cannot be accessed, they all have access rights, which is more secure.
2。 Inheritance: Refers to the ability to use all the functionality of an existing class and extend it without having to rewrite the original class. There are three ways to inherit: inheritance, interface inheritance, and visual inheritance.
3。 Polymorphism: Simply put, it allows a pointer of a child type to be assigned to a pointer of the parent class type. There are two ways to achieve polymorphism, method coverage and method overload. Briefly explain the difference between overloading and rewriting. Overloading is for the same class, the method name is the same, and the parameter list (type and quantity) is different. Rewriting is aimed at the construction method between the parent class and the subclass, and the subclass inherits the parent class, but this method subclass feels not suitable for its own use, so it rewrites this method by itself, the name of the method is the same, that is, the executor is a little different, and the execution action is more suitable for the subclass. Briefly describe the difference between abstract classes and interfaces. The methods in the interface must all be abstract methods Abstract classes can define both abstract methods and instance methods The difference between String and StringBuffer StringBufferis a string object with object reference transmission characteristics. StringBufferObjects can be called to dynamically increase, insert, modify and delete operations without specifying the size in advance like arrays, so as to achieve the effect of inserting characters multiple times and taking them out as a whole at one time, so the operation of strings is very flexible and convenient. Once passedStringBufferGenerate the final desired string and call ittoStringmethod to convert it into oneStringObject StringEach time it is added, it will apply for space to memory again and again, which is very inefficient StringBufferEach time you add up, you don't have to apply for space to memory again and again, becauseStringBufferIt requests a lot of memory space from the beginning, so it's efficient. What is an exception??What are the similarities and differences between runtime exceptions and general exceptions? What are the similarities and differences between runtime exceptions and general exceptions? Runtime Exception: An exception thrown by a Java virtual machine. Users don't have to deal with it. Generally exceptions are exceptions that users can throw, and if they do, they must be handled. A runtime exception represents an exception that may be encountered during the normal operation of a virtual machine and is a common running error. The Java compiler requires methods to declare a non-runtime exception that may occur, but it does not require that a runtime exception that is not caught must be declared. javaWhat are the sets and their generics, and what are the characteristics of each? set(set),list(list) andmap(Mapping)。
The differenceHASHMAPThere isKEYandvalueThe value corresponds.setIt is possible to automatically identify the same elements listis that its objects are stored in a linear way, without a specific order, only a beginning and an end, and of course, it is different from a set that has no order at all. Lists are represented in data structures as arrays and vectors, linked lists, stacks, and queues. Programming questions Create classes, have member variables, encapsulate them with read-write properties, add construction methods, have inheritance, and rewrite methods
javaoop1资料.doc
(78 KB, Number of downloads: 0, Selling price: 1 Grain MB)
|