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: https://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

  • An Overview On Ios 11 By Top Iphone App Development Companies In India
    By: Nirav Patel | Jan 6th 2018
    The finished version of the highly anticipated software iOS 11 is out now. Top-notch iPhone app development companies have already geared themselves with all the resources required to build an app for the latest iOS 11. Read

  • How Technology Impacted On Real Estate Sector
    By: hallmark builders | Jan 6th 2018
    Technology is used in different industries like hospitality, business, agriculture, communication, transportation, education and many more. As in the same way real estate sector has no exceptional with technology. There are few ways how real estate sector is depended on technology like marketing and advertising, People hunt ... Read

  • New Features In Java 8
    By: Infocampus | Jan 6th 2018
    Java 8 or JDK 1.8 is the most significant expansion of the Java language yet. Java 8’s new features such as Lambda Expressions, Stream APIs, Nashorn, Compact Profiles, new Time APIs increase the expressive power of the platform and make it easier for developers to take advantage of modern, multicore processors. This artic ... Read

  • Ios - 8 Principles Of Ios Development To Know Before Starting Your App
    By: Infocampus | Jan 6th 2018
    Building up a local iOS application can be a complex process. The developer you hire will be instrumental at all times, got the opportunity to be a professional with the correct blend of abilities to see your application through the outline and coding stages. That is the reason, before you begin searching for a designer; it ... Read

  • Understanding Python Basics
    By: Infocampus | Jan 5th 2018
    you will learn some Python basics, such as using the print function to display output. You will read about using variables and how to assign values to variables, and you will gain an understanding of their data types. By the end of this chapter, you will know how to get data into a script by using the input function and wri ... Read

  • Swift- A Powerful Open Language That Lets Everyone Build Amazing Apps.
    By: Infocampus | Jan 5th 2018
    Begin creating iOS Apps (Swift) is the ideal beginning stage for figuring out how to make applications that keep running on iPhone and iPad. View this arrangement of incremental lessons as a guided prologue to building your first application"including the instruments, significant ideas, and best practices that will facil ... Read

  • Implementing Iterable Interface In Java To Enable For-each Loop Based Iteration
    By: Infocampus | Jan 4th 2018
    how to implement java.lang.Iterable on a class to enable for-each loop based iteration through the collection of objects stored in that class. Tutorial starts off with explaining how Iterable and for-each loop are related, then explains how to implement Iterable, and finally shows a Java code example showing Iterable interf ... Read

  • Important Things You Need To Know About Selenium
    By: Infocampus | Jan 4th 2018
    Selenium can be a champion among the most able mechanical assemblies in the QA Engineers' munitions store. Shockingly, it can be dull to make, a terrible dream to keep up, and it can convey far an inordinate number of false negatives. Read

  • Swift -a New Programming Language For Os X And Ios
    By: Infocampus | Jan 3rd 2018
    With regards to speed, Swift is incredible. Swift is likewise present day with highlights like terminations, various return writes, and namespaces. Swift is totally local to both Cocoa and Cocoa Touch. Swift will be prepared for primetime out of the door," and will highlight "finish Xcode bolster." Additionally, when iOS ... Read

  • Learn Python Programming Step By Step
    By: Infocampus | Jan 3rd 2018
    we aim to teach all basic to advanced level Python programming concepts to a large no. of aspirants in the most efficient way. We've organized this course in such a manner that you can learn Python with least efforts, without investing a lot of your time and finally be able to apply this knowledge to your live projects. Read


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