Java Fundamentals 2

Source: Internet
Author: User

1. The keyword STRICTFP can only be used to decorate classes and methods and cannot be used to modify variables. Declaring a class as strictfp means that any method in the class will obey the IEEE754 standard of floating point (operation). If not stated, the floating-point (operation) used in the method may be platform-independent.

2. The abstract method can also be modified with the Abstraction keyword, but it is important to note that the method (function) decorated with the keyword is "();" Ending with "{}"! Also, as long as one method in a class is of type abstract, the entire class must be declared abstract. However, if a non-abstract method exists in an abstract class, it is legal (allowed). Note: Subclasses must implement all abstract methods of the abstract parent class, unless the subclass is also an abstract class.

Publicabstract class A {

abstract void foo ();

}

Class B extends A {

void foo (int I) {

}

}

This code is wrong, because although the subclass implements a method Foo, the method only overloads the parent class method (overload) instead of overlapping (override), because the parameters of the two methods are different, so the compilation goes wrong. Note: Abstract methods cannot be final or private type, because abstraction is convenient for the quilt class to inherit.

3. An instance variable (instancevariable) refers to a class member variable (member) that can use the public, protected, and private modifiers. You can also use transient, final, abstract, strictftp, native modifiers.

Remember: For an instance variable of the final type, it must be assigned manually at the time of declaration, because the constructor will not assign it to him automatically, or the compilation will go wrong, and remember: transient is used only on instance variables, as is the same as volatile.

4. Method overloading: Is the same as the name of the method in the same class, the number of single arguments, the type of the parameter, or the return value type is different.

Method overrides: The relationship between the subclass and the parent class, the subclass overrides the method of the parent class, but the method name, parameter type, and number of arguments must be the same.

5.

Java Fundamentals 2

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.