1. The method of implementing an abstract method in an interface in an implementation class of an interface must be public, why?
All of the methods and variables in the interface are public by default and can not be written in the interface. But in the implementation class, if not written, it becomes friend, that is, "package access permissions." Java also stipulates that when implementing an interface or overwrite a parent class method, the access rights of the parent method cannot be reduced, but can be improved. That is, you can improve access by friend protected public, but you cannot lower access rights by protected Friend.
Disprove: The interface implementation method is not defined to expose how you call the interface to find and run an internal method
2. An interface is a collection of definitions of abstract methods and constant values.
Interfaces can be thought of as a special abstract class in which abstract classes can have non-abstract methods, but the methods in an interface can only be public abstract types.
The variables in the interface are identified by default in public static final.
All methods that implement an interface, except abstract classes, that implement the interface.
3. In Java, the purpose of designing an interface is to allow a class to be constrained by a single inheritance, and to have the flexibility to inherit some common features to achieve multiple inheritance, and to avoid problems arising from multiple inheritance in C + +. The danger of multiple inheritance is that a class might inherit different implementations of the same method, which would never happen to the interface, because the interface has no implementation.
4. A class can implement one or more interfaces while inheriting a parent class, and the extends keyword must precede the Implements keyword.
5. The Equals method in the object class, which compares two objects for equality and the default value is False. Because of the inheritance nature of the class, the Equals method can be used in any class, but the return value is always false, and the result of the comparison is not necessarily accurate, so the Equals method in the object class must be overridden in the custom class. For example, the Equals method in the Java.lang.String class is overridden.
6. Use the instanceof operator to make a decision before casting, otherwise the classcastexception may be thrown.
7. The classes in the same package do not have to be in the same directory, such as Org.it315.Class1 and Org.it315.Class2, can be one in the C-drive location, and the other on the D-Drive, as long as the classpath points to two positions respectively.
8. javac-d. The difference between Abc.java and Javac Abc.java
Both are Abc.java compiled into the current directory, the difference is java-d. The specified directory is automatically created according to the package statement in the Java source file.
9. Naming habits in Java
The letters in the package are all lowercase
Class name, interface name, use noun, capitalize the first letter of each word
Method name, first word lowercase, first letter of each word in uppercase
Variable name, first word lowercase, first letter of each word in uppercase
Every letter in a constant name is capitalized
10. Cannot use absolute path when setting classpath at command line
For example: Add Abc.jar to the current classpath,
Set Classpath=%classpath%;c:\abc.jar
Jar is Java archive file, as long as the classpath contains the jar file, the Java Virtual machine can automatically extract the jar file in memory, the jar as a directory, In this jar file, look for the directory structure that corresponds to the class and package name you need.
The advantages of jar: On the one hand we can manage a large number of class files, on the other hand, compression also reduces the space occupied by the file.
12. Base jar Command:
Jar CF Test.jar Test, package The test directory under the current path into Test.jar
Jar CVF Test.jar test, as above, plus parameter V to show details of the packaging process.
Jar TVF Test.jar, which displays a list of all directories and files contained in the jar file, with V to show details such as the size of each directory and file, the creation time, and so on.
Jar XVF Test.jar, unzip the jar file to the current directory, with V to show details of the decompression process.
Jar TVF Test.jar > c:\rt.txt, using DOS redirection to output the contents of the screen to a file because the console has limited cache space and too much information, the previous information is overwritten by the following
The Java-verbose command can show the loading process of the ClassLoader.
14. Quickly enter a directory in the DOS command window
CD directory name, if the name of the directory is longer, you can enter only some of the characters in the directory name, and other characters with * instead.
. JVM Run Process
Java Basics Review (VI)