Java jumbled code, strings, methods

Java jumbled code, strings, methods

10th Grade

19 Qs

quiz-placeholder

Similar activities

Pre-test: On Online searching by Innovative Teaching Ideas)

Pre-test: On Online searching by Innovative Teaching Ideas)

6th - 12th Grade

14 Qs

Advantages and Disadvantages of Collecting Data

Advantages and Disadvantages of Collecting Data

10th Grade

20 Qs

¿Qué es un sistema operativo?

¿Qué es un sistema operativo?

10th Grade

19 Qs

Základní části počítače a ergonomie

Základní části počítače a ergonomie

9th - 10th Grade

16 Qs

Cyber Security KS4

Cyber Security KS4

8th - 12th Grade

15 Qs

Linux-2 Quiz 2 -- LAMP

Linux-2 Quiz 2 -- LAMP

1st - 12th Grade

15 Qs

Excel

Excel

10th - 12th Grade

15 Qs

HTML -znaczniki 1

HTML -znaczniki 1

7th Grade - University

15 Qs

Java jumbled code, strings, methods

Java jumbled code, strings, methods

Assessment

Quiz

Computers

10th Grade

Practice Problem

Medium

Created by

Roopa Pulapaka

Used 1+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

19 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

Find the correct code to find the reverse of a number. For example if the number is 234, the output should be 432

   while (n > 0) {

   n = n / 10;

            rem = n % 10;

         rev = (rev * 10) + rem;

      }


   while (n > 0) {

            rem = n % 10;

            rev = (rev * 10) + rem;

            n = n / 10;

        }

  while (n > 0) {

            rem = n % 10;

            rev = (rem * 10) + rev;

            n = n / 10;

        }

  while (n < 0) {

            rem = n % 10;

            rev = (rev * 10) + rem;

            n = n / 10;

        }

2.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Identify the code that gives the sum of the digits of a number? If the number is 567 the sum is 18

while (number > 0)  {  

number = number % 10;   

sum = sum + remainder;  

number = number / 10;     

System.out.print(sum)

while (number > 0)  {  

remainder = number / 10;   

sum = sum + remainder;  

number = number % 10;     

System.out.print(sum)

while (number > 0)  {  

remainder = number % 10;   

sum = sum + number;  

number = number / 10;     

System.out.print(sum)

while (number > 0)  {  

remainder = number % 10;   

sum = sum + remainder;  

number = number / 10;     

System.out.print(sum)


3.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

Identify the correct code to check if a number is prime or not. num is the number to check.

boolean flag = false

for (int i = 1; i <= num / 2; ++i)

{

if (num % i == 0) {

flag = true; break;

}

}

if (!flag) System.out.println("prime"); else

System.out.println(" not prime");

boolean flag = false

for (int i = 2; i <= num / 2; ++i)

{

if (num % i == 0) {

flag = true; break;

}

}

if (!flag) System.out.println("prime"); else

System.out.println(" not prime");

boolean flag = false

for (int i = 2; i <= num / 2; ++i)

{

if (num % i == 0) {

flag = true; break;

}

}

if (flag) System.out.println("prime"); else

System.out.println(" not prime");

boolean flag = true

for (int i = 2; i <= num / 2; ++i)

{

if (num % i != 0) {

flag = true; break;

}

}

if (!flag) System.out.println("prime"); else

System.out.println(" not prime");

4.

MULTIPLE CHOICE QUESTION

3 mins • 1 pt

identify the correct java code snippet to check if a String is a palindrome. Variable len is the length of the String.

boolean isPalin = true;

for (int i = 0; i < len / 2; i++) {

if (str.charAt(i) != str.charAt(len- 1 - i)) {

isPalin = false;

break;

} }

if (isPalin)

System.out.println("palindrome");

else

System.out.println("not palindrome.")

boolean isPalin = true;

for (int i = 0; i < len / 2; i++) {

if (str.charAt(i) != str.charAt(len- 1 - i)) {

isPalin = false;

break;

} }

if (!isPalin)

System.out.println("palindrome");

else

System.out.println("not palindrome.")

boolean isPalin = true;

for (int i = 0; i < len / 2; i++) {

if (str.charAt(i) == str.charAt(len- 1 - i)) {

isPalin = false;

break;

} }

if (isPalin)

System.out.println("palindrome");

else

System.out.println("not palindrome.")

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

what is the min and max value of short data type in Java?

-216 and 216-1

-215 and 215-1

-231 and 231-1

215 and -215-1

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

what is the default value of a boolean data type?

true

false

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

  1. A variable declared within the opening and closing parenthesis of a method signature is called a ____.

local

parameter

instance

class

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?