Advertisements
Advertisements
प्रश्न
Consider the given program and answer the questions given below:
class temp
{
int a;
temp()
{
a=10
}
temp(int z)
a=z;
}
void print()
{
System.out.println(a);
}
void main()
{
temp t = new temp();
temp x = new temp(30);
t.print();
x.print();
}
}
- What concept of OOPs is depicted in the above program with two constructors?
- What is the output of the method main()?
टिप्पणी लिखिए
उत्तर
- Polymorphism. Having two constructors in a class represents constructor overloading, which is a part of polymorphism.
- 10
30
shaalaa.com
Principles of Object Oriented Programming (OOP)
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?