Java easy to confuse knowledge points

Source: Internet
Author: User

1. The data storage in the computer is in the character unit (value -128~127), can store an English character, numeral, English punctuation. Because there are too many characters in a character range, you must use double-byte to store it.

The Java language is a char-type 16-bit (two-byte) that can store any character.

The default floating-point type for 2.java is double, when you assign a number of type double to float, you either try to force the type conversion or add F or F to the number.

3. & is two digits in binary form, bitwise logic and operation.

&& is typically used in conditional expressions to perform logic and operations on two or more relational expressions, which is a short-circuit operator, which is more efficient when the expression in front of it is false without a calculation behind it.

4.java how to jump out of multiple loops and work with continue to use the inner and outer loops of the terminal.

 Public Static void Main (String args[]) {     Label:            for (int. i=1;i<10;i++) {               for (int J =10;j>=0;j--) {                  if(j==5) {                   break label    ;             }}}}

What is the difference between 5.abstract class and interface?

Class that contains the abstract modifier is an abstract class, an instance object that the abstract class cannot create. A class containing an abstract method must be defined as an abstract Class,abstract class in which the method does not have to be abstracted. Abstract class definitions must be implemented in a specific (concrete) subclass, so there can be no abstract constructor or abstract static method. If the subclass does not implement all the abstract methods in the abstract parent class, then the subclass must also be defined as an abstract type.

An interface (interface) can be described as a special case of an abstract class, and all methods in an interface must be abstract. The method definition in the interface defaults to the public abstract type, and the member variable type in the interface defaults to public static final.

Here's a comparison of the syntax differences between the two:

1. Abstract classes can have construction methods, and interfaces cannot have constructors.

2. There can be ordinary member variables in the abstract class, there are no ordinary member variables in the interface

3. Abstract classes can contain non-abstract ordinary methods, all the methods in the interface must be abstract, and cannot have non-abstract ordinary methods.

4. Abstract methods in an abstract class can have access types public,protected and (the default type, although Eclipse does not give an error, but should not), but the abstract method in the interface can only be of the public type, and the default is the public abstract type.

5. Abstract classes can contain static methods, and interfaces cannot contain static methods

6. Both 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 the variables defined in the interface can only be public static final types, and the public static final type is the default.

7. A class can implement multiple interfaces, but can inherit only one abstract class.

Let's talk about the difference between the two applications:

Interface is more in the system architecture design method to play a role, mainly used to define the communication contract between the modules.

Abstract classes play a role in the implementation of code, and can implement code reuse.

6.String s = new String ("XYZ"); Two string object objects are created, one is "XyX" and one is a reference object that points to "XyX".

What is the difference between 7.== and equals?

= = is used to determine whether two reference variables point to the same object instance, and equals is used to determine whether two values are equal.

How many types of streams are there in 8.java?

The byte stream inherits from InputStream \ OutputStream,

The character stream inherits from InputStreamReader \ OutputStreamWriter.

9. Finalize is a method of the object class that, when executed by the garbage collector, calls this method of the reclaimed object, and can override this method to provide additional resource recycling when garbage collection occurs, such as closing a file.

Java easy to confuse knowledge points

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.