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 |
Is Exception handling possible in c language?
what is the advantage of using SEMAPHORES to ORDINARY VARIABLES???
#include<stdio.h> #include<conio.h> # define swap(a,b) temp=a; a=b; b=temp; void main( ) { int i, j, temp; i=5; j=10; temp=0; if( i > j) swap( i, j ); printf( "%d %d %d", i, j, temp); }
write a program structure to find average of given number
What are identifiers in c?
explain about storage of union elements.
What is a program flowchart and how does it help in writing a program?
How to run c Program without using IDE of c. means if program made in notepad.then how to compile by command prompt.
how to print this sereis 2 4 3 6 5..........?
What does struct node * mean?
Why is c platform dependent?
how to execute with out main in cprogram