Classic Questions (1)

Source: Internet
Author: User

1. Can the constructor Constructor be override?

A: The constructor Constructor cannot be inherited, so overriding cannot be overridden, but can be re-

Load overloading.

2.

Two object values are the same (x.equals (y) = = true), but can have different hash code, which

A sentence, right?

Answer: No, there is the same hash code.

3.

Can I inherit the String class?

A: The String class is the final class and therefore cannot be inherited.

4.

The following two statements return a value of true:

A: "Beijing" = = "Beijing";

B: "Beijing". Equalsignorecase (New String ("Beijing"));

Answer: A and B.

5.

When an object is passed as a parameter to a method, this method can change the properties of the object.

And can return the result of the change, so is it a value pass or a reference pass?

A: The value is passed. The Java programming language has only value-passing parameters. When an object instance is used as a parameter

When passed to a method, the value of the parameter is a reference to the object. The contents of the object can be called in the

method, but the object's reference is never changed.


Classic Questions (1)

Related Article

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.