MyPage is a personalized page based on your interests.The page is customized to help you to find content that matters you the most.


I'm not curious

Using Inheritance For Extended Classes in Offshore Java Development

Published on 02 October 14
256
0
0

Reusability is a common concept of any programming language. It would be great to reuse some code during offshore java development that has been already designed by some programmer. Java strongly follows the concept of reusability. Write the code for one class, test the code and it can be used by several programmers successfully. The process of driving a new class from the existing one is called inheritance. In technical terms, the old class is termed as base class and new one is termed as derived class. New class may inherit some or all properties of the old class. A class also has the capability of inheriting properties or traits from more than one class.


Single inheritance - Only one base class and one derived class

Multiple inheritance â Multiple base class and one derived class

Hierarchical inheritance â Multiple derived class and one base class

Multilevel inheritance â Driving new class from existing derived class

Hybrid Inheritance â Joining two or more types of inheritance together


Here we have added some pictures to make the learning process easier for you. Arrow directions will help you in determining direction of inheritance.


Defining Derived classes


A derived class is always defined by determining its relationship with base class with its own personal details.

The visibility mode may be public or private according to programmerâs requirement. If you are not defining any visibility â mode then it is set private by default. Visibility âmode states that properties of base class are derived either publicly or privately.

When a derived class inheriting base class privately then public members of old class becomes private members of new class and thereof public members of old class can only be accessed by member function of new class. They are not accessible to the objects of new class. Donât forget that public members of a class can be accessed by its own objects using dot (.) operator. As a result, base class members are not accessible to derived class objects.

At the other side, when a derived class inheriting base class privately then public members of old class becomes public members of new class and thereof they are accessible to the objects of new class. In the both cases, it is not possible to inherit the private members of a base class or we can say it is not possible to access private members of any base class in either situation.


Virtual Base Classes

Consider a situation where we have to use all three types of inheritance namely multilevel, multiple, and hierarchical. In this case, few members of a particular class are inherited twice. This increases the ambiguity that should be avoided. Virtual base class strictly prohibits ambiguity, regardless of how many inheritance paths exist between the virtual base class and a derived class. To make any base class virtual, you just have to add virtual keyword in front of it.

At the end we conclude that by using inheritance, we can add certain data elements to our program. Further, we can extend the class by adding our own data elements to improve the credibility and functionality of a program. Extending classes in Java application development using inheritance is taken wonderful tool for incremental program development.

Source: http://tech.pro/blog/2548/using-inheritance-extended-classes-offshore-java-development










Reusability is a common concept of any programming language. It would be great to reuse some code during offshore java development that has been already designed by some programmer. Java strongly follows the concept of reusability. Write the code for one class, test the code and it can be used by several programmers successfully. The process of driving a new class from the existing one is called inheritance. In technical terms, the old class is termed as base class and new one is termed as derived class. New class may inherit some or all properties of the old class. A class also has the capability of inheriting properties or traits from more than one class.

Single inheritance - Only one base class and one derived class

Multiple inheritance â Multiple base class and one derived class

Hierarchical inheritance â Multiple derived class and one base class

Multilevel inheritance â Driving new class from existing derived class

Hybrid Inheritance â Joining two or more types of inheritance together

Here we have added some pictures to make the learning process easier for you. Arrow directions will help you in determining direction of inheritance.

Defining Derived classes

A derived class is always defined by determining its relationship with base class with its own personal details.

The visibility mode may be public or private according to programmerâs requirement. If you are not defining any visibility â mode then it is set private by default. Visibility âmode states that properties of base class are derived either publicly or privately.

When a derived class inheriting base class privately then public members of old class becomes private members of new class and thereof public members of old class can only be accessed by member function of new class. They are not accessible to the objects of new class. Donât forget that public members of a class can be accessed by its own objects using dot (.) operator. As a result, base class members are not accessible to derived class objects.

At the other side, when a derived class inheriting base class privately then public members of old class becomes public members of new class and thereof they are accessible to the objects of new class. In the both cases, it is not possible to inherit the private members of a base class or we can say it is not possible to access private members of any base class in either situation.

Virtual Base Classes

Consider a situation where we have to use all three types of inheritance namely multilevel, multiple, and hierarchical. In this case, few members of a particular class are inherited twice. This increases the ambiguity that should be avoided. Virtual base class strictly prohibits ambiguity, regardless of how many inheritance paths exist between the virtual base class and a derived class. To make any base class virtual, you just have to add virtual keyword in front of it.

At the end we conclude that by using inheritance, we can add certain data elements to our program. Further, we can extend the class by adding our own data elements to improve the credibility and functionality of a program. Extending classes in Java application development using inheritance is taken wonderful tool for incremental program development.

Source: http://tech.pro/blog/2548/using-inheritance-extended-classes-offshore-java-development

This blog is listed under Development & Implementations Community

Related Posts:
Post a Comment

Please notify me the replies via email.

Important:
  • We hope the conversations that take place on MyTechLogy.com will be constructive and thought-provoking.
  • To ensure the quality of the discussion, our moderators may review/edit the comments for clarity and relevance.
  • Comments that are promotional, mean-spirited, or off-topic may be deleted per the moderators' judgment.
You may also be interested in
Awards & Accolades for MyTechLogy
Winner of
REDHERRING
Top 100 Asia
Finalist at SiTF Awards 2014 under the category Best Social & Community Product
Finalist at HR Vendor of the Year 2015 Awards under the category Best Learning Management System
Finalist at HR Vendor of the Year 2015 Awards under the category Best Talent Management Software
Hidden Image Url

Back to Top