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

CopyBits(x,p,n,y) copy n LSBs from y to x starting LSB at 'p'th position.

9 Answers   Adobe,


List the difference between a While & Do While loops?

0 Answers   Accenture,


Is c++ based on c?

0 Answers  


write a program to find the number of even integers and odd integers in a given array in c language

13 Answers   IAI Cameroun, NIIT, Olive Tech, QIS,


1,1,5,17,61,217,?,?.

3 Answers   Apple,


A stack can be implemented only using array?if not what is used?

3 Answers   InterGlobal,


What is true about the following C Functions a.Need not return any value b.Should always return an integer c.Should always return a float d.Should always return more than one value.

11 Answers   TCS,


How can I discover how many arguments a function was actually called with?

0 Answers  


Explain what is output redirection?

0 Answers  


What are type modifiers in c?

0 Answers  


#include main() { int i=1,j=2; switch(i) { case 1: printf("GOOD"); break; case j: printf("BAD"); break; } }

6 Answers   ME,


Can you write a programmer for FACTORIAL using recursion?

0 Answers   ADP,


Categories