--%>

How class and a structure are different

How class and a structure are different?

E

Expert

Verified

a.) Class:

  • The class is a reference type.
  • During instantiating the class, CLR assigns memory for its instance in heap.
  • Class supports inheritance.
  • Variables of the class could be allotted as null.
  • It can contain constructor or destructor.


b.) Structure:

  • The structure is a value type.
  • Memory is assigned on stack.
  • It does not support inheritance.
  • Members of Structure could not have null values.
  • It do not need constructor or destructor and members could be initialized automatically.

   Related Questions in Programming Languages

  • Q : Define Short-circuit operator

    Short-circuit operator: It is an operator in which only as a lot of operands are computed as are required to determine the final outcome of the operation. The logical-and (&&) and logical-or (||) operators are most general illustration, though

  • Q : Define Delegation Delegation : The

    Delegation: The procedure by which an object passes on a message has received to a sub-ordinate object. When inheritance is not accessible in a programming language, then delegation is the most viable option for ignoring code duplication and promoting

  • Q : What is Homogeneous collection

    Homogeneous collection: A group of objects with similar dynamic type. Arrays are the most general homogeneous collection objects.

  • Q : Retrieve the text for ORA-12705 Normal

    Normal 0 false false

  • Q : What is Control structure Control

    Control structure: A statement which affects the flow of control in a method. The typical control structures are if statements and loops.

  • Q : Define the term Top level class Define

    Define the term Top level class: It is a class defined either at outermost level of a package or the static nested class.

  • Q : CORBA In what respects did CORBA seek

    In what respects did CORBA seek to improve on technologies such as SunRPC?

  • Q : Type promotion rule Q. Explain type

    Q. Explain type conversion rules for basic data types in java. Ans. Type promotion rule: Java automatically each bits or short operant to int when evaluating an expression. As usual as the automatic promotion

  • Q : What is Bookmark Bookmark : It is

    Bookmark: It is employed by a Web browser to memorize details of a Uniform Resource Locator (URL).

  • Q : What is Character set encoding

    Character set encoding: The set of values allocated to characters in a character set. Associated characters are frequently grouped with consecutive values, like the digits and alphabetic characters.