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
What are the general description for loop statement and available loop types in c?
What do you mean by scope of a variable in c?
How can type-insensitive macros be created?
What is the purpose of 'register' keyword?
What is a floating point in c?
What is a union?
What is a lvalue
What is abstract data structure in c?
What is the difference between struct and union in C?
The difference between printf and fprintf is ?
What are the differences between Structures and Arrays?
What is echo in c programming?
What is an auto keyword in c?
Can you please explain the difference between exit() and _exit() function?
WHICH TYPE OF JOBS WE GET BY WRITING GROUPS .WHEN THE EXAMS CONDUCTED IS THIS EXAMS ARE CONDUCTED EVERY YEAR OR NOT.PLS TELL ME THE ANSWER