Solved

What Is Displayed After Executing the Given Code Snippet

Question 16

Multiple Choice

What is displayed after executing the given code snippet?
Int[] mymarks = new int[10];
Int total = 0;
Scanner in = new Scanner(System.in) ;
For (int cnt = 1; cnt <= 10; cnt++)
{
System.out.print("Enter the marks: ") ;
Mymarks[cnt] = in.nextInt() ;
Total = total + mymarks[cnt];
}
System.out.println(total) ;


A) The code snippet displays the total marks of all ten subjects.
B) The for loop causes a run-time time error on the first iteration.
C) The code snippet causes a bounds error.
D) The code snippet displays zero.

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions

Unlock this Answer For Free Now!

View this answer and more for free by performing one of the following actions

qr-code

Scan the QR code to install the App and get 2 free unlocks

upload documents

Unlock quizzes for free by uploading documents