Correct answer should be A, C and E. If you would take into account that the return-statement in method setCCount is misspelled, then the code would not compile and that answer is not an option. If you can only choose two then it should be C and E but in that case the code would not work at all.
A is incorrect because -The method setCCount(int) is undefined for the type
B is incorrect because - The left-hand side of an assignment must be a variable
D is incorrect because - The assignment to variable tCount has no effect...
C& E Are correct answers
public class DNASynth {
int aCount;
int tCount;
int cCount;
int gCount;
DNASynth(int a, int tCount, int c, int g){
cCount = setCCount(c);
aCount = a;
setGCount(g);
}
int setCCount(int c){
return c;
}
void setGCount(int gCount){
this.gCount = gCount;
}
public static void main(String[] args) {
DNASynth pop = new DNASynth(1,2,3,4);
System.out.println(pop.aCount+" "+pop.cCount+" "+pop.gCount); // 1 3 4
}
}
The correct answers: A C E
A is not correct because it has "retutn".
B is not correct because setC returns an int and it doesn't set anything.
D is not correct because both refer to the parameter variable, not the class variable.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Samps
1 year, 1 month agod7bb0b2
1 year, 1 month ago[Removed]
1 year, 4 months agoStavok
1 year, 8 months agoRoxyFoxy
1 year, 8 months agoMukes877
1 year, 8 months agoSuperDabicho
1 year, 9 months agoyokito
6 months agoAnkit1010
1 year, 12 months agoRP384
2 years agoUcefSoft
2 years, 2 months agoUcefSoft
2 years, 2 months ago