Search Header Logo

Day 17

Authored by Venkatesh iGen

Computers

Professional Development

Used 5+ times

Day 17
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

22 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

public class Main {

    public static void main(String[] args) {

        String s = "abc";

        int sum = 0;

        for (char c : s.toCharArray()) {

            sum += c;

        }

        System.out.println(sum);

    }

}

294

297

300

303

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

public class Main {

    public static void main(String[] args) {

        String s = "a1b2c3";

        int sum = 0;

        for (int i = 1; i < s.length(); i += 2) {

            sum += s.charAt(i) - '0';

        }

        System.out.println(sum);

    }

}

6

3

5

4

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

public class Main {

    public static void main(String[] args) {

        int[] arr = {513, 46, 29};

        int max = 0;

        for (int num : arr) {

            while (num > 0) {

                max = Math.max(max, num % 10);

                num /= 10;

            }

        }

        System.out.println(max);

    }

}

6

5

9

3

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

public class Main {

    public static void main(String[] args) {

        String s = "6589";

        char[] arr = s.toCharArray();

        char temp = arr[0];

        arr[0] = arr[arr.length - 1];

        arr[arr.length - 1] = temp;

        System.out.println(new String(arr));

    }

}

6589

9586

9865

9568

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

public class Main {

    public static void main(String[] args) {

        int[] a = {10, 20, 30};

        int sum = 0;

        for (int i = 1; i < a.length; i++) {

            sum += a[i] - a[i - 1];

        }

        System.out.println(sum);

    }

}

20

10

30

40

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

public class Main {

    public static void main(String[] args) {

        String[] s = {"abc", "de", "fghi"};

        int count = 0;

        for (String str : s) {

            count += str.length();

        }

        System.out.println(count);

    }

}

4

8

5

9

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

public class Main {

    public static void main(String[] args) {

        int n = 237541;

        int count = 0;

        while (n > 0) {

            int d = n % 10;

            if (d == 2 || d == 3 || d == 5 || d == 7) count++;

            n /= 10;

        }

        System.out.println(count);

    }

}

6
5
4
3

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?