
Java jumbled code, strings, methods
Quiz
•
Computers
•
10th Grade
•
Practice Problem
•
Medium
Roopa Pulapaka
Used 1+ times
FREE Resource
Enhance your content in a minute
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
A variable declared within the opening and closing parenthesis of a method signature is called a ____.
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

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
14 questions
Logičke izjave i funkcije
Quiz
•
8th - 10th Grade
22 questions
Steve Jobs
Quiz
•
6th - 12th Grade
22 questions
1.2.4 Data Storage - OCR
Quiz
•
9th - 10th Grade
16 questions
Introduction to Programming Vocabulary
Quiz
•
9th - 12th Grade
16 questions
Computer Science 2.2
Quiz
•
10th Grade
20 questions
Technology Innovations
Quiz
•
5th - 12th Grade
18 questions
PC Component Identification
Quiz
•
6th - 12th Grade
16 questions
Python programming
Quiz
•
6th - 12th Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
