Create a class with one integer instance variable. Initialize the variable using:
(i) default constructor
(ii) parameterized constructor.
It's very urgent please de fast
Answers
Answered by
41
class p1
{
int a; >>>>> value for default cons.
p1() >>>>> default constructor
{
a=0; >>> value assigned to def. cons.
}
void main()
{
..... >>>> here u can write things for main
}
}
class p1
{
int a;
p1(int x) >>>> parameterized cons.
{
a=x;
}
void main()
{
...... >>>> here u can write things for main
}
}
Answered by
3
Answer:
answer is in the above attachment
Attachments:
Similar questions