India Jobs- IT Fresher Job in Delhi, Bangalore, Mumbai, Chennai.
www.Lkshya.com
Ask Your Query

Q. What is a Constructor in Java?




Characters Left
8 + 0
Yusup
Cjfhhchud
rajashree
constructor in java is a special type of method that is used to intialize the object. java is invoked at the time of object creation it constructs the values provides data for the object that is why it is known as constructor.
Mansvini Avhad
Definition: Constructor are special methods which are used to initialize the object,constructor methods has the same name as like class name . And also it must define without return type . Syntax : Class Class_name { ..... Class_name() { ..... //Default Constructor } Class_name(Parameter Type 1) { ..... //Parameterized Constructor }. . Class_name(Parameter Type N) { ..... //Parameterized Constructor } ..... ..... } Properties: 1-Constructor should require same name as like class. 2-Constructor call automatically after creating object of class 3-Constructor don't have "return type" . 4-Constructor define in our program with "public keyword". Where private keyword is not allowed.
Prasoon Jain
A constructor in Java is a method with no return type and name as that of the class in which it is created. A constructor is automatically invoked by the JVM for initializing the instance variables of a class when its object being created. There are basically 2 types of constructor in Java. 1. Default Constructor 2. Parameterised Constructor The Constructor with no parameters is called Default Constructor while the constructor with parameters is called Parameterised Constructor. The Default Constructor is only invoked by the JVM when no other programmer defined constructor is available. example : class Demo { private String name; // instance variable Demo { // default constructor name="My Name"; } Demo(String n) { // parameterised constructor name=n; } }
Attri
In Java constructor name class name are same.while compiling the code JVM 1st check for the constructor that means for an object. BLOCK REPRSENTATION In Java block construction of a constructor doesn't have any return type Ex:public A()//constructor Ex: public void C()//method Here in above constructor method name and class are always same. An constructor is not inherited into derived class of base class.
deepthi
constructor is a special member function/method in java which gets executed whenever an object is created.
Datta
Constructor is a block of code that allows you to create an object of class. This can also be called creating an instance. Constructor looks like a method but it?s not, for example methods can have any return type or no return type (considered as void) but constructors don?t have any return type not even void. There are several other differences between them, we will discuss them in detail at the end of this article.
Akash Srivastava
A constructor is a bit of code that allows to create objects from a class. To call the constructor we use the keyword new followed by the name of the class followed by some parameters Every class has at least 1 constructor. Java generates a default constructor in case no used defined constructors found else if user defines a constructor for the class then java skips to generate a default constructor.
abhishek choubey
Constructors are the special methods of a class which is use to initialize the object. But not to create the object. And initialization takes place only once in life cycle of objects Constructor are by default static.
Bijoy chandra saha
A constructor in Java is a block of code similar to a method that's called when an instance of an object is created. Here are the key differences between a constructor and a method: A constructor doesn't have a return type. The name of the constructor must be the same as the name of the class.
Manoj Kumawat
Constructor:- It is special type of method. when we are create object than it automatically work. 2. Constructor name should be same as class name. 3. we can not create object inside the constructor. 4. constructor return type always void, so we can not return any values but return the control where it is called. 5. constructor can not support inheritance. 6. They number of times object is create same number of constructor call.
James Smith
constructor in Java a method that's called when an instance of an object is created.A constructor doesn't have a return type. The name of the constructor must be the same as the name of the class. A constructor is a bit of code that allows you to create objects from a class
Neeraj paliwal
Constructor is a special type of method that is used to initialize an object. It is invoked at the time of object creation... It's name same as the class name. Constructor does not inherited.. It does not support return type..
aashish silswal
constructor is special type member function..it's name same as class name.....and it's invoke at object creation time.we can call constructor without initialization(anonymous object).
Lokesh
Constructor is method used to create the object of the class
Ali
Constructor is a special kind of method that determines how an object is initialized when created. Constructor name must be the same as the class name and it could be parametrized or non-parametrized, and if we don't declare the constructor the main method by default invoke the default constructor for the object creation process.... Did you get it Mr. Haider Ali.
Haider Ali
i do not know please help me
Top Answered Questions Good at tech answer these

Some other Good Questions

Q:1 What is a Constructor in Java?

Q:2 How are positive(+ve) and negative(-ve) numbers represented internally in Java?

Q:3 What do Trojans, Viruses, and Other Malware do to our systems?

Q:4 Can abstract class have constructor in java?

Q:5 Difference between checked vs unchecked exception in Java?

Q:6 When is checked exception in Java?

Q:7 What is difference between == and equals() while comparing strings? Which one is reliable?

Q:10 Can we call a class a data type?

Q:11 What is the difference between #include and import statement?

Q:12 What is JIT Compiler?

Q:13 What is a swap space in Linux?

Q:14 What is the basic difference between BASH and DOS?

Q:15 How do you refer to the parallel port where devices such as printers are connected?

Q:16 How do you switch from one desktop environment to another, such as switching from KDE to Gnome?

Q:17 How does case sensitivity affect the way you use commands?

Q:18 Is it possible to use shortcut for a long pathname?

Q:19 How do you terminate an ongoing process?

Q:20 Write a command that will display all .txt files, including its individual permission in Linux.

India Jobs-How to get fresher software jobs in India| Search Jobs