The Gateway to Computer Science Excellence
0 votes
138 views

How many constructors can a class have?

(A) zero              (B) 1

(C) 2                   (D) any number

in Object Oriented Programming by Loyal (7.3k points)
recategorized by | 138 views

2 Answers

+2 votes
Best answer
Any number of constructors are allowed, provided their parameters differ from each other.

Example-

Class A{

int a, b;

A(){

this.a=5;

}

A(int a){

this.a=a;

}

A(int a, int b){

this.a=a;

this.b=b;

}

}
by Active (2.9k points)
selected by
0 votes
Ans: D
by Loyal (7.3k points)
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,367 answers
198,496 comments
105,267 users