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 |
What is sizeof array in c?
How to convert a binary number to Hexa decimal number?? (Note:Do not convert it into binary and to Hexadecimal)
though sbi was nationalized why its not comes under nationalized banks and its comes under publicsector banks
3 Answers State Bank Of India SBI,
Difference between strcpy() and memcpy() function?
N O S I E R + A S T R A L ---------------- 7 2 5 6 1 3
What is Lazy evaluation in C? Give an example.
write a program that uses point of sale system. which are mainly used by retail markets, where the is a database inventory list, a slip should be printed for the customer. manage should be able to access what has been sold and what is left from stock?
What are qualifiers in c?
How can you tell whether a program was compiled using c versus c++?
What’s the special use of UNIONS?
What is the difference between null pointer and wild pointer?
Do pointers need to be initialized?