Java Second Experiment

Source: Internet
Author: User
(a) Study summary 1. What is a construction method? What is an overload of a constructor method? Can the following program be compiled? Why?
  • The constructor method definition method is similar to the normal method, where the primary function is to initialize the properties in the class, the name of the construction method is consistent with the class name, and there is no return value.
  • Overloading of constructor methods: The method name is the same, the parameter type and number are different.

    public class Test {public static void main(String args[]) {    Foo obj = new Foo();       }     }class Foo{int value;public Foo(int intValue){    value = intValue;}}
  • The above program cannot be compiled because the constructor method foo is undefined.

Java Second Experiment

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.