To Review of Java - subjective questions

  1. JDK and JRE What is the difference?
    JDK: Java Development Kit for short, java development kit that provides java development environment and runtime environment.
    JRE: Java Runtime Environment abbreviation, java runtime environment, provides the necessary environment for the java runtime.
    Specifically JDK actually contains the JRE, also contains the source code to compile java compiler javac, also it contains a lot of java debugging and analysis tools. In short: if you need to run java program, simply install the JRE on it, if you need to write java program, you need to install JDK.

  2. HashCode two objects () are the same, equals () certainly is true, right?
    Right, hashCode two objects () the same, equals () is not necessarily true. Because in the hash table, the hashCode () that is equal to two key-hash value are equal, but equal to the hash value, not necessarily equal to the derived key.

  3. What is the role in the final of java?
    final modified class called final class, which can not be inherited.
    The final modification method can not be overridden.
    final modified variable called, const must be initialized, after initialization value can not be modified.

  4. String belongs to the basic data type?
    String type does not belong to the foundation, there are 8 basic types: byte, boolean, char, short , int, float, long, double, and String objects belong.

  5. What are the operating string java class? What is the difference between them?
    String class operation are: String, StringBuffer, StringBuilder.
    And the StringBuffer String, String difference lies StringBuilder statements are immutable objects, each operation generates a new String object, then the pointer to the new String object, and the StringBuffer, StringBuilder may be operated on the basis of the original object, so it is best not to use string in the case of frequent changes in the contents of strings.
    StringBuffer and StringBuilder biggest difference is that, StringBuffer is thread-safe, but StringBuilder is not thread-safe, but the performance is higher than StringBuffer StringBuilder, so in single-threaded environment is recommended to use StringBuilder, StringBuffer is recommended to use a multithreaded environment.

  6. String str = "i" and the String str = new String ( "i ") the same?
    Not the same, because the memory is allocated differently. String str = "i" way, java virtual machine to be assigned to the constant pool; and String str = new String ( "i ") will be assigned to the heap.

  7. How to reverse a string?
    Use StringBuilder or stringBuffer the reverse () method.

  8. An abstract class must be abstract way?
    Not necessarily, for example, it can only contain normal static method.

  9. General classes and abstract classes What are the differences?
    Common classes can not contain abstract methods, abstract class may contain abstract methods.
    An abstract class can not be directly instantiated general class can be instantiated directly.

  10. Interfaces and abstract classes What is the difference?
    Implementation: a subclass of abstract class to use extends inheritance; implements the interface must be used to implement the interface.
    Constructor: abstract class constructor can; can not have the interface.
    main methods: the main method of abstract class can have, and we can run it; the interface can not have a main method.
    Achieve Quantity: class can implement many interfaces; it can only inherit an abstract class.
    Access modifiers: public interface method using the default modification; abstract class method may be any access modifiers.

  11. java in IO stream is divided into several?
    Divided by function: input stream (input), the output stream (output).
    Divided by type: byte stream and character stream.
  12. The difference between a byte stream and character stream
    byte stream transmitted in 8-bit bytes of input and output data, 16-bit transmission character stream in units of characters input and output data.

Note: All the above excerpt from the public micro-channel number "java lessons learned" is not my original, only to learn reference.

Guess you like

Origin www.cnblogs.com/KeepZ/p/11920855.html