Note . Data Structure . struct     Last updated on          

 

struct Structure Concept in Java

 

Data Structure

Class

struct    XYZ {

 

                        data-type1        variable1;

                        data-type2        variable2;

                        data-typeN-1   variableN-1;

                        data-typeN       variableN;

 

                        }

 

class    ABC  {

 

                        data-type1        variable1;

                        data-type2        variable2;

                        data-typeN-1   variableN-1;

                        data-typeN       variableN;

 

void Method1( ) { … }  

void Method2( ) { … }

void MethodN-1( ) { … }

void MethodN { … }

 

                        }

 

Note: After executing the above codes, XYZ becomes structural variable. Data-type varies upon programming languages.

 

Note: After executing the above codes, ABC structure itself and  its member functions are all combined together, and ABC becomes an existence, a single entity, called a class. 

Notice that such a data structure becomes a class. It is known as Encapsulation.

struct    XYZ     ijk;  

Note: After executing the above codes, ijk becomes a newly created XYZ type data structure.

ABC    ooo;

Note: After executing the above codes,

 

class    efg    extends    ABC { … }

Note: After executing the above codes, class efg  inherits both data-type 1~N and Method 1~N from class ABC. It is known as Inheritance.     

 

In OOP, any function which takes any parameter values regardless of data-types  is called polymorphic function. It is known as Polymorphism, which consists of Inheritance, Interfacing, and Overloading.

Also see: Polymorphism in OOP ;

 

 

 

Up