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 |
c programming of binary addition of two binary numbers
When can a far pointer be used?
what is the output of the following program? #include<stdio.h> void main() { int x=4,y=3,z; z=x-- -y; printf("\n%d %d %d",x,y,z); }
Can you please explain the difference between malloc() and calloc() function?
What is spark map function?
What is void main () in c?
Write a code of a general series where the next element is the sum of last k terms.
How can you allocate arrays or structures bigger than 64K?
Describe the header file and its usage in c programming?
What is strcpy() function?
What is the difference between specifying a constant variable like with constant keyword and #define it? i.e what is the difference between CONSTANT FLOAT A=1.25 and #define A 1.25
Explain in detail how strset (string handling function works )pls explain it with an example.