Q.– Given this array:-
int [ ] intArr = { 6, 12, 24, 48, 96 };
Which two code fragments, independently, print each element in this array?
A) for (int i=0; i < intArr.length ; i++) {
System.out.print (i + " ");
}
B) for (int i : intArr) {
System.out.print (i + " ");
}
C) for (int i ; i < intArr.length ; i++) {
System.out.print (intArr[i] + " ");
}
D) for (int i=0 : intArr) {
System.out.print (intArr[i] + " ");
i++;
}
E) for (int i=0 ; i < intArr.length ; i++) {
System.out.print (intArr[i] + " ");
}
F) for (int i : intArr) {
System.out.print(intArr[i] + " ");
}
⧪ please give your answer in a comment section.
int [ ] intArr = { 6, 12, 24, 48, 96 };
Which two code fragments, independently, print each element in this array?
A) for (int i=0; i < intArr.length ; i++) {
System.out.print (i + " ");
}
B) for (int i : intArr) {
System.out.print (i + " ");
}
C) for (int i ; i < intArr.length ; i++) {
System.out.print (intArr[i] + " ");
}
D) for (int i=0 : intArr) {
System.out.print (intArr[i] + " ");
i++;
}
E) for (int i=0 ; i < intArr.length ; i++) {
System.out.print (intArr[i] + " ");
}
F) for (int i : intArr) {
System.out.print(intArr[i] + " ");
}
⧪ please give your answer in a comment section.
6 Comments
Option B F
ReplyDeleteD E
ReplyDeleteB and E
ReplyDeleteB E
ReplyDeleteB E
ReplyDeleteBE
ReplyDelete