What are the examples in programming? What is an instance? What is instantiation? What is a class? What is an object? __ Programming

Source: Internet
Author: User
instance (instance)In object-oriented programming, "class" is called an "instance" after instantiation. "Class" is static, does not occupy process memory, and "instance" has dynamic memory. In a database, represents a collection of programs. As in Oracle, examples are database programs that support the operation of a database. Instances (instance) and objects (object) are essentially synonyms and are often used interchangeably. object represents a specific instance of a class. Objects have identities (identity) and attribute values (attributes) 2 characteristics. An instance is a concrete representation of an object, an action can be applied to an instance, and an instance can store the results of the operation in a state. Examples are used to simulate things that exist, specific, or archetypal in the real world. An object is an instance of a class, all objects are instances, but not all instances are objects. For example, an instance of an association (one in a uml relationship) is not an object, it is just an instance, a connection. Our common instances are instances of the class, and there is no difference. Instances other than instances of a class are not objects.


instantiation in object-oriented programming, the process of creating objects with classes is often referred to as instantiation. (Procedure for creating an object with a Class) format class Name Object name = new class name (); In object-oriented programming, the process of creating objects with classes is often called instantiation, and the format is as follows: Class Name Object name = new class name (parameter 1, parameter 2 ...). Parameter n); such as date date=new date (), an object that creates a date with a date class, is called an instantiation of the object. In most languages, instantiating an object is to open up memory space for an object, or to use the new constructor name () directly to create a temporary object without declaring it. Example: Java

public class a{public
    static void Main (string[] args) {
        b = new B ();//instantiating
        b.print ();
    }
}
Class b{public
    void print () {
        System.out.println ("hello,world!");
    }

Example: C #
Namespace Test
{
    class A
    {public
        int Sub (int A)
        {return
            a++;
        }
    }
 
    Class B
    {public
        void Main (string[] args)
        {
            int p = (new A ()). Sub (1);
            System.Console.WriteLine (p);
            System.Console.ReadKey ();}}



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.