Java Class/method

Source: Internet
Author: User

    • A class can has only public or default (no modifier) access specifier.
    • It can be either abstract, final or concrete (normal class).
    • It must has the Class keyword, and class must is followed by a legal identifier.
    • It may optionally extend one parent class. By default, it'll extend Java.lang.Object.
    • It may optionally implement any number of comma-separated interfaces.
    • The class ' s variables and methods are declared within a set of curly braces {} .
    • Each . Java source file could contain only a public class. A source file may contain any number of the default visible classes.
    • Finally, the source file name must match the public class name and it must has a. java suffix.

How a class was initialized in Java

Class is initialized in Java when a instance of class is created using either new operator or using reflection using

Class.forName (). A class is also said to being initialized when a static method of class was invoked or a static filed is assigned

How to make a copy of the entire Java object with it state

Make this class implement cloneable interface and call Clone () method on the its Object.clone () method was defined in Object class which is the parent of any Java class by default.

Java Method:

In Java if you pass a primitive type to a method It's pass by value

When you pass the object of any of the type to a method it is passed as reference

Java Class/method

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.