what is default constructor?

Answers were Sorted based on User's Feedback



what is default constructor?..

Answer / venugopal

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

what is default constructor?..

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

Post New Answer

More C Interview Questions

Is Exception handling possible in c language?

0 Answers   Wipro,


what is the advantage of using SEMAPHORES to ORDINARY VARIABLES???

2 Answers   NSN,


#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); }

9 Answers   Burning Glass,


write a program structure to find average of given number

1 Answers  


What are identifiers in c?

0 Answers  






explain about storage of union elements.

2 Answers   ABC, Bosch,


What is a program flowchart and how does it help in writing a program?

0 Answers  


How to run c Program without using IDE of c. means if program made in notepad.then how to compile by command prompt.

1 Answers   HP, TCS,


how to print this sereis 2 4 3 6 5..........?

3 Answers  


What does struct node * mean?

0 Answers  


Why is c platform dependent?

0 Answers  


how to execute with out main in cprogram

15 Answers   Infosys,


Categories