Computer Science, asked by fazlur19, 5 months ago

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 xNiGhTmRx
41

\huge\mathtt\blue{Answer}

\huge\mathtt\pink{i}

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

}

}

\huge\mathtt\green{ii}

class p1

{

int a;

p1(int x) >>>> parameterized cons.

{

a=x;

}

void main()

{

...... >>>> here u can write things for main

}

}

Answered by Aria07
3

Answer:

answer is in the above attachment

Attachments:
Similar questions