UPDATED MCQ PRACTICE PDF
Document Details

Uploaded by WellWishersDecagon
Tags
Summary
This PDF contains multiple-choice questions (MCQs) related to arrays and loops in Java programming. The questions cover basic concepts and potential errors. It's suitable for undergraduate-level computer science students practicing Java.
Full Transcript
UPDATED MCQ PRACTICE 1. Arrays and Loops Q1: What is the output of the following code? java Copy code int[] numbers = {1, 2, 3, 4, 5}; int sum = 0; for (int i = 0; i < numbers.length; i++) { if (i % 2 == 0) { sum += numbers[i]; } } System.out.println(sum); A) 9 B...
UPDATED MCQ PRACTICE 1. Arrays and Loops Q1: What is the output of the following code? java Copy code int[] numbers = {1, 2, 3, 4, 5}; int sum = 0; for (int i = 0; i < numbers.length; i++) { if (i % 2 == 0) { sum += numbers[i]; } } System.out.println(sum); A) 9 B) 12 C) 8 D) 15 Q2: What is wrong with the following code? java Copy code int[] arr = new int; for (int i = 0; i