what is constructer?what are the type of constructer with
example.

Answers were Sorted based on User's Feedback



what is constructer?what are the type of constructer with example...

Answer / sandesh nawadkar

Constructor is a same as method but it isnot exactly a
method . It has same name as a Class. It has access
specifier but not return type. Constructor is used to
create and initialize objects at runtime.
There are different types of constructors in different oop
languages.
e.g. Consider, java language-there are two types:-
1. Default
2. Parameterized.

Is This Answer Correct ?    12 Yes 1 No

what is constructer?what are the type of constructer with example...

Answer / kool

A constructer has same name as class .it does not have any
data type in a program we can only have one constructer
with a class name because they can be overloaded.if we dont
create one the programe creates one for us.

public class kool{

/** constructer

public kool(){
*/
}
}

Is This Answer Correct ?    5 Yes 5 No

what is constructer?what are the type of constructer with example...

Answer / sunil prasad

Constructor is a specail type of mrthod.constructor name
should be same with the class name
There is defferent type of construtor:-
default constructor
parameter constructor
default construtor automatically call when we create
object of class.

Is This Answer Correct ?    1 Yes 1 No

what is constructer?what are the type of constructer with example...

Answer / shiva krishna

class Shiva
{
public Shiva() // it is a constructor
{
//code
}
}
class Mainclass
{
public static void main(String args[])
{
Shiva obj=new Shiva();
}
}

explanation: the code written in constructor is
automatically executed when we create object for the
class.no need to call the constructor/method again.

point to note:
constructor must not have any return type

Is This Answer Correct ?    1 Yes 1 No

what is constructer?what are the type of constructer with example...

Answer / prasad

A constructor is a method.it used to custom intialization
for an object.constructor name and class name is same.
consructor should not return any value not even void also.
A constructor will Executed at the time of initialization of
an object.
Different types of constructors:
--------------------------------
1)default constructor
2)parametarized constructor
Ex:


class sum{
int a,b;//instance variables
sum(int a,int b){
System.out.printl("sum of two numbers="+(a+b));
}
}
class Example{
psvm(String s[])throws Exception{
sum s=new sum(10,10);
}
}
o/p:sum of two numbers=20
/*here the constructor will be executed at the time of
creating the object*/

Is This Answer Correct ?    0 Yes 2 No

what is constructer?what are the type of constructer with example...

Answer / devender

write answer i n 2nd

Is This Answer Correct ?    0 Yes 3 No

Post New Answer

More Java Related AllOther Interview Questions

How do I download and install eclipse on windows 10?

0 Answers  


What is interceptors in java?

0 Answers  


What is the point of lambda expressions?

0 Answers  


What is repository pattern in java?

0 Answers  


What is aop in java?

0 Answers  






How do I enable java in firefox?

0 Answers  


What is custom tag in java?

0 Answers  


Topic- looping,function overloading,nesting ,polymorphism. Aim - to write a function with a name buzz-buds,that will check whether the given numbers are buddies or not on the basis of no. of parameters passed during function calling.

0 Answers  


can a program use more than one command-line argument?

0 Answers  


How do you create a jar file?

0 Answers  


why java has the size of character 2 byte ,while in c/c++ it is of 1 byte?

8 Answers   IBS,


How can I protect myself? : java security

0 Answers  


Categories