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 |
how to find out the biggest element (or any other operation) in an array which is dynamic. User need not to mention the array size while executing.
What is the difference between exit() and _exit()?
What are the different types of constants?
where are auto variables stored? What are the characteristics of an auto variable?
int main() { unsigned char a = 0; do { printf("%d=%c\n",a,a); a++; }while(a!=0); return 0; } can anyone please explain me output????
Is null a keyword in c?
write a program to find the sum of the array elements in c language?
24 Answers ICT, Infosys, Wipro,
main() { int ptr[] = {1,2,23,6,5,6}; printf("%d",&ptr[3]-&ptr[0]); }
Explain about the constants which help in debugging?
#include <stdio.h> int main ( int argc, char* argv [ ] ) { int value1 = 10; int value2 = 5; printf ( "\n The sum is :%d", value1 | value2 ); } This is the answer asked by some one to add two numbers with out using arithmetic operator?Yes this answer is write it given out put as 15.But how????? what is need of following line? int main ( int argc, char* argv [ ] ) how it work?what is the meaning for this line? please explain me.Advance thanks
What is Function Pointer? Explain with example?
What is the difference between functions abs() and fabs()?