Print This Article Post Comment Add To Favorites Email to Friends Ezine Ready

In Java , How Can We Inherit The Constructor

By: Infocampus Home | Computers-and-Technology


What is constructor?
Constructor is a special type of method that always holds the class name and it is mainly used to initialize the object. It construct the values for the object .So it is known as constructor.

Constructor is of two types:
[i] Zero argument constructor(default constructor)
[ii] Parameterized constructor

Zero Argument Constructor: When we don’t pass any argument in constructor. That is known as zero argument constructor.If user defined constructor is not there then compiler will generate zero argument constructor known as default constructor.

Parameterized constructor: When we pass the argument in constructor known as parameterized constructor. Advance java training in bangalore In it we can pass any no. Of argument.

Properties of Constructor :
[1]It is same as the class name.
[2]It does not having any return type or return statement.
[3]It has access modifiers.
[4]It is neither static nor nonstatic.

What is Constructor Chaining:
Calling a constructor from another constructor , is known as constructor chaining.If we want to access the properties of any constructor then we have to use constructor chaining.
We know that constructor is neither static nor non static. So we can’t inherit the constructor.But using constructor chaining we can acquire the properties of another constructor.
Note: Constructor is a special type of method that always holds the class name.java/j2ee classes bangalore It is not a method but it consist of the same behaviour as a method.

How can we achieve the constructor chaining ?
There is two ways to achieve the constructor chaining:
[1] super() : super() (call to super) is used to call the super class constructor. That mean sub class is able to access the properties of constructor which are present in super class. For accessing the super class constructor properties inheritance is must.
If user is not defined the super() then compiler generates as the first statement in the class.But if user defined constructor is there compiler never generate java course in bangalore the super().
[2] this(): this()(call to this) is used to call the same class constructor. That mean we can achieve the properties of constructor which are present in the same class. For using this() constructor overloading is necessary. Without constructor overloading we can’t get the properties of same class.
Note: super() and this() should be the first statement. Because of that both can’t be present in the same class.

What is need of constructor chaining ?
[1]Access the properties: Constructor chaining is used to access the properties of constructor in the same class or in another class.
[2]Code optimization :Using constructor chaining java training center bangalore we achieve code optimization ,means lines of code get reduced.
[3]Maintenance easy : Using constructor chaining maintenance easy because if we keep the common functionality in super class constructor.So we need to change only in super class constructor.
[4]Memory will get reduced : If same code will repeat at multiple times then more memory will used. to avoid this we use constructor chaining, we access the same code.Then less memory used.

Difference between super() and this()
1) super() is used to call super class constructor, best core java training in bangalore this() is used to call same class constructor.
2) For super() inheritance is necessary because for achieving the super class constructor we use the concept of sub and super class. For this() constructor overloading is necessary.
3) If userdefined super() is not there compiler generate super().But this() is not generate by the compiler, we have to explicitly define the this().

This is short description about the constructor & constructor chaining. To get the more knowledge on java and getting the free 100% job support join Infocampus Software Training Institute for making the career in java






Article Source: http://www.eArticlesOnline.com

About the Author:
Infocampus provides advance java training in bangalore with 100% placement assistance and real time project.It provides core and advance java training in lesser fees and also payments in installament facility is available.

Learn OOPs concept,packages,thread,spring & hibernate etc in java course.Attend 4 days free demo classes for java training. Infocampus provides java/j2ee classes in bangalore .It prepares the learners to crack the interview easily.Complete practical session is available for best core java training.

To get the free demo classes and for 100% job support call at : 9738001024 or to get the syllabus about java course enquire at : http://www.infocampus.co.in/java-training-bangalore.html

Tags: , , , , , , ,

Please Rate this Article

 

Not yet Rated

Click the XML Icon Above to Receive Computers-and-Technology Articles Via RSS!

Recent Related Articles From Computers-and-Technology

  • Common Wordpress Issues | Fix Wordpress Site
    By: 24/7 wordpress support | wordpress website repair | Oct 17th 2017
    We’re going to talk briefly about security and WordPress error, concepts to help you keep your site safe. Read

  • Brief Description About Applet
    By: Infocampus | Oct 16th 2017
    Applet is an extraordinary kind of program that is introduced in the site page to create the dynamic substance. It continues running inside the program and works at client side. Read

  • New Jersey It Support- Why Help Desk Is Highly Essential For Every Business
    By: Vikram Kumar | Oct 14th 2017
    As one of the online business owners, you have perhaps heard the term- Help Desk. This is such an asset that the entrepreneurs consider for the convenience of users Read

  • It Support For Nj Businesses - Why Should You Have Server Virtualization Solutions
    By: Vikram Kumar | Oct 14th 2017
    When your business has presently a traditional server system, it may be able to run only one application. Lots of companies, having this system, need to make a deployment of a number of servers Read

  • Oops Concept Forms The Basis Of Java Programming Language
    By: Infocampus | Oct 13th 2017

    OOPs concept forms the basis of Java Programming Language, I will try to answer your question in a very layman language.
    OOPs stands for Object Oriented Programming. An approach to do programming which is based on Objects (or real life objects).
    Read

  • Sending Off Harmful Adware & Spyware- Sakshi Computers
    By: Sakshi | Oct 13th 2017
    The Internet is a wonderful tool. It works like a virtual web, connecting everyone within its network from all parts of the globe. With numerous striking highlights, the Internet has turned out to be popular to the point that for all intents and purposes everybody around the globe approaches an Internet association. This po ... Read

  • Anti-virus Support New Jersey - To Protect A Computer System
    By: Vikram Kumar | Oct 13th 2017
    The present online world has allowed lots of companies to alter their business-related approaches. However, any file that you have stored on the web platform may face the risk of the virus Read

  • Offsite Data Backup Strategy In New Jersey- Protect The Lost Files
    By: Vikram Kumar | Oct 13th 2017
    An efficient management of business data is highly important to every company. As the business owners do their transactions with the help of computer systems, they have to ensure the security of all data

    Read

  • Introduction Of Java Jdbc
    By: Infocampus | Oct 12th 2017
    Before JDBC, ODBC API was the database API to relate and execute question with the database. In any case, ODBC API uses ODBC driver which is created in C lingo (i.e. organize destitute and unsecured). That is the reason Java has described its own particular API (JDBC API) that usages JDBC drivers (written in Java tongue). Read

  • Why All Businesses Have Started Depending On Computer & It Support Nj
    By: Vikram Kumar | Oct 12th 2017
    Every business owner wants to increase revenue with smarter and better innovations. Presently, information technology has caused a revolution in almost all the business sectors

    Read


Copyright © 2005-2015 eArticlesOnline, LLC - All Rights Reserved
Terms of Service | Privacy Policy