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

  • Hibernate A Framework For Mapping In Java
    By: Infocampus | Apr 28th 2017
    Hibernate is an object-relational mapping (ORM) library for Java language, providing a framework for mapping an object-oriented domain model to a traditional relational database. Read

  • Software Development Services
    By: abigaylemark1 | Apr 27th 2017
    Companies, professional and individuals often require custom software applications to run their operations smoothly. Some are reticent to hiring a team of professionals for the task, thinking they don’t need it so much, but there are many benefits that come from personalized software development. It all depends on the com ... Read

  • Why Invest In Modded Controllers Xbox One
    By: abigaylemark1 | Apr 27th 2017
    If you are used to playing online games and not using anything that might help you become better at it, you should know that you have been missing out on a long list of advantages that are usually associated with modded controllers xbox one. The same goes if you check out modded controllers ps4 and do not really know whethe ... Read

  • Where Can You Find Mod Controllers Ps4?
    By: abigaylemark1 | Apr 27th 2017
    Even though you might believe that you can come across mod controllers xbox one in gaming stores that can be found in your area, you should know that this would be impossible seeing as these products are usually hard to get by. At the same time, you might want to know that mod controllers ps4 that actually work and offer yo ... Read

  • Which Smartphone For Which Purpose?
    By: Antoine | Apr 27th 2017
    Nowadays there are many Smartphone brands and more than a thousand of different mobile are available on the market. In this universe of electronic devices, it is easy to get lost when you want to buy a Smartphone. Which one is the best for you? What kind of phone should you choose which is the most adapted to your need and ... Read

  • How Does The Digital Egt Gauge Actually Works?
    By: Joseph Polizzotto | Apr 27th 2017
    EGT gauges are found in specific autos and planes. By observing EGT, the driver or pilot can get a thought of the vehicle's air-fuel proportion. Read

  • In Java How Collection Is Single Unit Of Objects
    By: Infocampus | Apr 26th 2017
    A collections framework is a unified architecture for representing
    and manipulating collections. Collection represents a single unit of objects i.e. a group.
    Read

  • Packages A Mechanism Which Makes The Code Easy In Java
    By: Infocampus | Apr 25th 2017
    A java packages is a collection of comparative sorts of classes, interfaces and sub-packages. Packages in java can be arranged in two forms: built-in packages and user defined packages. Read

  • Gmail Help & Support Gmail Technical Support Number: 1-888-996-3777
    By: JASTINE | Apr 24th 2017
    gmail password Forget
    How To Reset Gmail Password
    Gmail Hijacked
    How To Set up a Gmail Account in cell phone
    How To Set up a Gmail On IPhone
    How To Restore Gmail Contacts
    How To Change Gmail Password
    How To Recover Gmail Password
    Forget Gmail Recovery Option
    Gmail Troubl ...
    Read

  • Exception Handling A Concept To Avoid The Program Terminate Improperly In Java
    By: Infocampus | Apr 22nd 2017
    When java executing any faulty statement , an interruption occur or program terminated improperly .that is known as exception.We need to handle the exception using exception handling mechanism. Read


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