Java jumbled code, strings, methods

Java jumbled code, strings, methods

10th Grade

19 Qs

quiz-placeholder

Similar activities

Computer Science Unit 3 Test

Computer Science Unit 3 Test

9th - 12th Grade

15 Qs

Java Lab Code.org AP CSA

Java Lab Code.org AP CSA

9th - 12th Grade

18 Qs

Java Decision/Selection Self-Check

Java Decision/Selection Self-Check

9th - 12th Grade

20 Qs

สอบกลางภาค JAVA เรียนที่ 1/2562

สอบกลางภาค JAVA เรียนที่ 1/2562

KG - 12th Grade

15 Qs

Review for Test If else and for loops

Review for Test If else and for loops

10th - 12th Grade

22 Qs

AP CSA Arrays

AP CSA Arrays

10th - 12th Grade

14 Qs

Exploring Computer Science

Exploring Computer Science

10th - 12th Grade

14 Qs

Traversing Arrays

Traversing Arrays

10th - 12th Grade

14 Qs

Java jumbled code, strings, methods

Java jumbled code, strings, methods

Assessment

Quiz

Computers

10th Grade

Medium

Created by

Roopa Pulapaka

Used 1+ times

FREE Resource

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

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?