Answer Posted / 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 |
Post New Answer View All Answers
Explain what are its uses in c programming?
What do you mean by Recursion Function?
What are the characteristics of arrays in c?
Write a program to generate the Fibinocci Series
How to get string length of given string in c?
Write a program to reverse a linked list in c.
What is scope and lifetime of a variable in c?
What are the different types of control structures in programming?
Explain null pointer.
What is difference between static and global variable in c?
What's a good way to check for "close enough" floating-point equality?
How main function is called in c?
Explain what is #line used for?
how is the examination pattern?
‘ C’ PROGRAME TO SHOW THE TYPE OF TRANGLE BY ACCEPTING IT’S LENGTH .