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

What is interceptors in java?

0 Answers  


What is a dao layer in java?

0 Answers  


What is meant by swing in java?

0 Answers  


What is the java api?

0 Answers  


What happens when you omit a brace or misspell one of the words, like public or

0 Answers  


What is jndi datasource in java?

0 Answers  


What is transient in java?

0 Answers  


How do I open java console?

0 Answers  


Describe the principles of oops.

0 Answers  


1.can i use super keyword in normal class(not inheritance) to call any method?if so how can i call particular variable? 2.In the inheritance how can i access the particular variable from the base class(it containing 5 variables) using super keyword?

0 Answers  


What is the content of the Java 2 security policy file?

1 Answers  


What is exe file in java?

0 Answers  


Categories