Java jumbled code, strings, methods

Java jumbled code, strings, methods

10th Grade

19 Qs

quiz-placeholder

Similar activities

Microsoft Excel

Microsoft Excel

KG - Professional Development

20 Qs

Tech Trivia, Part III

Tech Trivia, Part III

7th - 12th Grade

20 Qs

Data Manipulation IGCSE (Introduction to database) Grade 10

Data Manipulation IGCSE (Introduction to database) Grade 10

10th - 11th Grade

20 Qs

CHỦ ĐỀ A. MÁY TÍNH VÀ XÃ HỘI TRÍ THỨC P1

CHỦ ĐỀ A. MÁY TÍNH VÀ XÃ HỘI TRÍ THỨC P1

10th Grade

20 Qs

SHEET QUIZ

SHEET QUIZ

9th - 12th Grade

15 Qs

A2 Computer Science  4.10 Databases

A2 Computer Science 4.10 Databases

10th - 12th Grade

16 Qs

Computing figures

Computing figures

4th - 12th Grade

14 Qs

XI TEKNOLOGI JARINGAN BERBASIS LUAS (WAN) Ke 1

XI TEKNOLOGI JARINGAN BERBASIS LUAS (WAN) Ke 1

1st - 10th Grade

20 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?