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
where are auto variables stored? What are the characteristics of an auto variable?
Explain that why C is procedural?
What is "Duff's Device"?
write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list
What is the difference between union and structure in c?
How to create struct variables?
How does sizeof know array size?
Write a program to print all permutations of a given string.
What is the benefit of using an enum rather than a #define constant?
What is .obj file in c?
What is the difference between arrays and pointers?
Explain a file operation in C with an example.
What is the purpose of realloc()?
Find the second largest element in an array with minimum no of comparisons and give the minimum no of comparisons needed on an array of size N to do the same.
Explain how do you override a defined macro?