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 |
CopyBits(x,p,n,y) copy n LSBs from y to x starting LSB at 'p'th position.
List the difference between a While & Do While loops?
Is c++ based on c?
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,?,?.
A stack can be implemented only using array?if not what is used?
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.
How can I discover how many arguments a function was actually called with?
Explain what is output redirection?
What are type modifiers in c?
#include main() { int i=1,j=2; switch(i) { case 1: printf("GOOD"); break; case j: printf("BAD"); break; } }
Can you write a programmer for FACTORIAL using recursion?