what is default constructor?

Answers were Sorted based on User's Feedback



what is default constructor?..

Answer / venugopal

In d object_oriented programs actually we interacting with
the methods with the objects only.Objects are constructed
when we create an object the compiler automatically calls
one constructor i.e default constructor.if we explicitily
mention a constructor i.e if we pass any arguments it is
called explicit constructor.
This can be briefly explained based on below ex. i am
writing d code in java.
class Sample
{
int x,y;
Sample()
{
x=12;
y=13;
}
Sample(int a,int b)
{
x=a;
y=b;
}
void display()
{
System.out.println("values are"+x+y);
}
}
class SampleDemo
{
public static void main(String args[])
{
Sample s=new Sample();//default constructor;
s.display();
Sample s1=new Sample(12,13);//parameterized constructor
s1.display();
}
} if u have any doubts contact me
venugopal.palavalasa@gmail.com

Is This Answer Correct ?    1 Yes 0 No

what is default constructor?..

Answer / vaibhav

in java once the memory is instantiated at that time constructor will call by internally.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

Explain the properties of union. What is the size of a union variable

0 Answers  


Is main is user defined function?

0 Answers  


write a c program to find the sum of five entered numbers using an array named number

0 Answers   TATA,


What are derived data types in c?

0 Answers  


What is an expression?

0 Answers  






which operator is known as dummy operator in c?

2 Answers   Wipro,


Differentiate call by value and call by reference?

0 Answers   Cyient,


What is the difference between GETS();AND SCANF();

4 Answers   TCS,


Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?

0 Answers  


how to find string length wihtout using c function?

6 Answers  


Differentiate between Macro and ordinary definition.

0 Answers   Motorola,


what is ans for this scanf(%%d",c);

1 Answers  


Categories