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 does the c in ctime mean?
Is c# a good language?
How do I use void main?
how to find anagram without using string functions using only loops in c programming
What is the meaning of && in c?
What is the difference between text and binary modes?
How can I make it pause before closing the program output window?
What is the code for 3 questions and answer check in VisualBasic.Net?
what is the height of tree if leaf node is at level 3. please explain
WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?
What is the use of a conditional inclusion statement in C?
Where are some collections of useful code fragments and examples?
In c language can we compile a program without main() function?
Write a C program on Centralized OLTP, Decentralized OLTP using locking mechanism, Semaphore using locking mechanism, Shared memory, message queues, channel of communication, sockets and a simple program on Saving bank application program using OLTP in IPC?
code for quick sort?