Code Mastery Challenge

Code Mastery Challenge

12th Grade

15 Qs

quiz-placeholder

Similar activities

Parts of Speech Test Review (continued)

Parts of Speech Test Review (continued)

9th - 12th Grade

10 Qs

สอบแก้ตัวกลางภาค 1/2565 ภาษาอังกฤษ อ่าน-เขียน

สอบแก้ตัวกลางภาค 1/2565 ภาษาอังกฤษ อ่าน-เขียน

12th Grade

15 Qs

AP CSA - Unit 6 - Arrays

AP CSA - Unit 6 - Arrays

9th - 12th Grade

17 Qs

Aw and Au Challenge

Aw and Au Challenge

2nd Grade - University

15 Qs

Consonant Digraphs and Trigraphs

Consonant Digraphs and Trigraphs

3rd Grade - University

15 Qs

Sentence Clauses, Types, and Purpose Take-Home Test

Sentence Clauses, Types, and Purpose Take-Home Test

9th - 12th Grade

20 Qs

Vocabulary - present simple, present continuous

Vocabulary - present simple, present continuous

9th - 12th Grade

10 Qs

Spelling

Spelling

1st Grade - Professional Development

10 Qs

Code Mastery Challenge

Code Mastery Challenge

Assessment

Quiz

English

12th Grade

Hard

Created by

Lakshmi Bollepalli

Used 1+ times

FREE Resource

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Debug the following code snippet: int x = 5; for(int i = 0; i < x; i++) { System.out.println(i); }

The loop will print numbers from 1 to 5

No issues found in the code snippet.

The loop will print numbers from 0 to 4

The loop will print numbers from 0 to 5

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Optimize the performance of the following code: for(int i = 0; i < 1000; i++) { System.out.println(i); }

Adding a sleep statement inside the loop

Using a LinkedList instead of StringBuilder

StringBuilder sb = new StringBuilder(); for(int i = 0; i < 1000; i++) { sb.append(i).append('\n'); } System.out.println(sb.toString());

Removing the loop and printing each number individually

3.

MULTIPLE CHOICE QUESTION

5 mins • 1 pt

Solve the real-world problem: Given an array of integers, find the maximum difference between any two elements.

The correct answer is to find the maximum difference between any two elements in the array of integers by subtracting the minimum value from the maximum value.

Sort the array in descending order

Find the average of the elements in the array

Calculate the sum of all elements in the array

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Debug the following code snippet: String str = 'Hello World'; System.out.println(str.substring(0, 5));

String str = 'Hello World'; System.out.println(str.substring(0, 6));

String str = 'Hello World'; System.out.println(str.substring(0, 5));

String str = "Hello World"; System.out.println(str.substring(0, 5));

String str = 'Hello World'; System.out.println(str.substring(1, 5));

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Optimize the performance of the following code: List numbers = new ArrayList<>(); for(int i = 0; i < 1000000; i++) { numbers.add(i); }

List numbers = new ArrayList<>(); for(int i = 0; i < 1000000; i++) { numbers.add(i); numbers.remove(0); }

List numbers = new ArrayList<>(); for(int i = 0; i < 1000000; i++) { numbers.add(0, i); }

List numbers = new ArrayList<>(1000000); for(int i = 0; i < 1000000; i++) { numbers.add(i); }

List numbers = new LinkedList<>(); for(int i = 0; i < 1000000; i++) { numbers.add(i); }

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Solve the real-world problem: Implement a function to check if a given string is a palindrome.

function checkPalindrome(str) { return str === str.split('').reverse().join(''); }

function isPalindrom(str) { return str === str.split('').reverse().join(''); }

function palindromeCheck(str) { return str === str.split('').reverse().join(''); }

function isPalindrome(str) { return str === str.split('').reverse().join(''); }

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Debug the following code snippet: int[] arr = {1, 2, 3, 4, 5}; for(int i = 0; i <= arr.length; i++) { System.out.println(arr[i]); }

int[] arr = {1, 2, 3, 4, 5}; for(int i = 0; i < arr.length; i++) { System.out.println(arr[i]); }

int[] arr = {1, 2, 3, 4, 5}; for(int i = 0; i < arr.length - 1; i++) { System.out.println(arr[i]); }

int[] arr = {1, 2, 3, 4, 5}; for(int i = 1; i < arr.length; i++) { System.out.println(arr[i]); }

int[] arr = {1, 2, 3, 4, 5}; for(int i = 0; i < arr.length; i++) { System.out.println(arr[i]); }

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?