Java Fundamentals 5

Source: Internet
Author: User

1. How are the lengths of arrays, strings, and collections obtained?
Array name. Length; property
String. Length (); method
Collection. Size (); method


2. What are the characteristics of arrays?
1. is a continuous memory space, subscript starting from 0, the maximum subscript is the length-1;
2. Each element is a variable;
3. The type of the element and the type of the definition array are identical;
4. By the length property to get the size of the array, once the built length of the array cannot be changed;
5. After the array is built, each element is initialized; int----0 Double----0.0 reference type-----NULL


3. What are the key words for inheritance? Subclass inherits the parent class, how should the first sentence of the construction method be written?
Following the keyword extends
Subclass inherits the parent class, constructs the method the first sentence: Super ();
Calls the parent class's construction method to produce the parent class object;


4. What is the difference between rewriting and overloading? What are the requirements for rewriting?
Overloads occur in the same class, with the same method name, with different parameter lists (parameter type, number of arguments, parameter order), and regardless of the return type, the virtual machine determines which overloaded method to invoke based on the contents of the argument;
Overrides occur between the parent class and the child class, with the same overriding method name and the same return type for the parameter list;
The access modifier must be greater than or equal to the modifier of the parent class, and the method that the subclass overrides is called when the method is called;
Throws an exception that is less than or equal to the exception thrown by the parent class;


5. Can a class in Java inherit multiple classes at the same time? What is the parent class for all classes?
No, a class in Java can inherit only one parent class;
The parent class of all classes is Object

Java Fundamentals 5

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.