what is default constructor?
Answers were Sorted based on User's Feedback
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 |
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 |
Explain the properties of union. What is the size of a union variable
Is main is user defined function?
write a c program to find the sum of five entered numbers using an array named number
What are derived data types in c?
What is an expression?
which operator is known as dummy operator in c?
Differentiate call by value and call by reference?
What is the difference between GETS();AND SCANF();
Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?
how to find string length wihtout using c function?
Differentiate between Macro and ordinary definition.
what is ans for this scanf(%%d",c);