An instance variable is an attribute of a class.
You determine the class size by adding the size of all its attributes.
You declare an instance of a class by first reserving memory for the class using the new operator followed by the constructor of the class ( new RegistrationForm() ). Next, declare a reference to the class and give that reference a name ( RegistrationForm myRegistrationform ). Finally, assign a reference to the memory reserved for the class to the reference using an assignment statement.
An instance variable is declared by specifying the data type of the variable, followed by the variable name, and ending with a semicolon within the body of a class definition.
A data type is a keyword that tells the computer the kind of data you want to store in a memory location.
A method definition consists of the name of a method, an argument list (if any), the data type of the value returned by the method, and the method body.
Although some programmers consider an argument list and a parameter list to be the same thing, other programmers consider a parameter list to be values passed to a method when the method is called, and they consider an argument list to be values defined within the method definition that receive values passed to the method.
A member method is called by first declaring an instance of a class and then using the name of the instance followed by the dot operator and the name of the method ” myInstance.myMethod() , for example.
A constructor is a method of a class that is called automatically when an instance of a class is declared. A constructor is defined in the class and must have the same name as the class name. A class can have multiple constructors, each with a different argument list. The argument list is traditionally used with the constructor to initialize instance variables of the class.
An instance variable is accessed by first declaring an instance of a class and then using the name of the instance followed by the dot operator and the name of the variable ” myInstance.myVariable , for example.