The foundation that I have seen in the last two days, I know the new
1,abstract class and interface differences:
Abstract class: • Can have non-abstract member variables
• Can have non-abstract member methods
• Subclasses must implement all methods in the parent class, or they must be defined as abstract classes
Interface: • Member method default modifier is public abstract
• Member variable default modifier is public static final
Difference:
• You can have a constructor in an abstract class, no interface
• Abstract classes can have non-abstract methods, interfaces can not
• Allow header normal member variables in abstract class, interface can not
• Abstract classes can contain static methods, interfaces cannot be
• Abstract classes and interfaces can contain static member variables, and the access type of static member variables in an abstract class can be arbitrary, but only the public static final type in the interface.
• A class can implement multiple interfaces, but can inherit only one abstract class
2. Object-oriented features
Encapsulation: An object is the basic unit of the object, which encapsulates the properties and behavior of the object into a module, realizing the "high cohesion, low coupling" feature within the software. Prevent the impact of procedural interdependencies. That is, the method of manipulating the same thing and the related method are put into the same class, and the method and the data of his operation are placed in the same class.
Inheritance: When writing a class, it can be implemented on the basis of a completed class that can take the contents of a completed class and can add new content or modify the original method to make it more suitable for the needs. Inheritance improves the reusability and scalability of software.
Polymorphic: Refers to the specific type that a reference variable points to or a method call made through the reference variable at run time. This allows the reference variable to be bound to the implementation on different classes without modifying the code, thus invoking different methods. (The Reference object that corresponds to the parent class or interface points to a subclass or implementation class that is indeterminate during compilation and is determined at run time)
Abstraction: The common denominator of things is written as a class, focusing only on the similarities of these things.
The difference between 3,== and equals
= =: The value used to compare two variables is equal, that is, whether the values stored in the memory that the object points to are equal. For reference variables, such as Object obj = new Object (), obj is a variable, and new object () is a variable, and the value of the variable obj is the first address of the memory space corresponding to obj.
equals: A content value that is used to compare two independent variables. such as String a1 = new String ("a"); String a2 = new String ("a"); A1==a2, the return value is FALSE,A1 equals A2 return value is true.
4, basic data type
Boolean,byte,short,char,int,float,double,long
The difference between 5,string and StringBuffer
The same: Both can be used to store and manipulate strings.
The difference: string provides a literal value that cannot be changed. The Equals () and Hashcode () methods are overridden. StringBuffer can modify the string.
The difference between 6,final,finally,finalize
Final: Used to declare variables, methods, and classes. Indicates that the variable is immutable, the method is not overwritten, and the class cannot be inherited.
Finally: A statement in the exception handling mechanism. The expression is always executed.
Finalize: Is a method of the object class that invokes the method of the reclaimed object when the garbage collector executes it.
The difference between 7,overload and override (inheritance or implementation)
Overload: Overloaded, the method name is different from the same parameter list.
· You can use overloads only with different parameter styles
• cannot be overloaded with access rights, return type, thrown exception
Override: Override, method name and parameter list are identical
• Overridden method flags, return values, and throws an exception that must be consistent with the method being overridden.
Java Face question-basics