100% de satisfacción garantizada Inmediatamente disponible después del pago Tanto en línea como en PDF No estas atado a nada 4,6 TrustPilot
logo-home
Examen

CODEHS AP COMPUTER SCIENCE A (Nitro) ITERATION QUIZ QUESTIONS WITH 100% CORRECT ANSWERS!!

Puntuación
-
Vendido
-
Páginas
9
Grado
A+
Subido en
07-05-2024
Escrito en
2023/2024

CODEHS AP COMPUTER SCIENCE A (Nitro) ITERATION QUIZ QUESTIONS WITH 100% CORRECT ANSWERS!!

Institución
CODEHS AP COMPUTER SCIENCE
Grado
CODEHS AP COMPUTER SCIENCE









Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.

Escuela, estudio y materia

Institución
CODEHS AP COMPUTER SCIENCE
Grado
CODEHS AP COMPUTER SCIENCE

Información del documento

Subido en
7 de mayo de 2024
Número de páginas
9
Escrito en
2023/2024
Tipo
Examen
Contiene
Preguntas y respuestas

Temas

Vista previa del contenido

CODEHS AP COMPUTER SCIENCE A (Nitro)
ITERATION QUIZ QUESTIONS WITH 100%
CORRECT ANSWERS!!
QUESTION 1:
Write a method that loops until the user inputs the correct secret password or
until the user fails to enter the correct password 10 times. The secret password
the program should look for is the String "secret"

Assume that a Scanner object called input has been correctly initialized.
ANSWER: C
public void secretPassword()
{
int count = 0;
while(true)
{
if(count == 10)
{
System.out.println("You are locked out!");
return;
}
String readLine = input.nextLine();
if(readLine.equals("secret"))
{
System.out.println("Welcome!");
return;
}

count++;
}
}
QUESTION 2:
What would the method call myMethod("Karel The Dog", 'e') output?

public int myMethod(String x, char y)
{
int z = 1;
for(int i = 0; i < x.length(); i++)
{
if(x.charAt(i) == y)
{
z++;
}
}

, return z;
}
ANSWER: C
3
QUESTION 3:
What kind of error would the method call myMethod("Frog") cause?

public void myMethod(String x)
{
for(int i = 0; i <= x.length(); i++)
{
System.out.println(x.substring(i, i+1));
}
}
ANSWER: B
Runtime Error: String index out of range
QUESTION 4:
What will the call to the method funWithNumbers(314159) print to the screen?

public void funWithNumbers(double myDouble)
{
int myInt = (int) myDouble;
String myString = "";
while(myInt != 0)
{
myString = myInt % 10 + myString;
myInt /= 10;
}
System.out.println(myString);
}
ANSWER: A
314159
QUESTION 5:
What does the call to the method someMethod(3,1) output?

public int someMethod(int x, int y)
{
int sum = 0;
while (x < 10)
{
sum += x % y;
x++;
y++;
}
return sum;
}
$13.49
Accede al documento completo:

100% de satisfacción garantizada
Inmediatamente disponible después del pago
Tanto en línea como en PDF
No estas atado a nada

Conoce al vendedor

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
Aplusplus Havard School
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
3827
Miembro desde
1 año
Número de seguidores
90
Documentos
6021
Última venta
14 horas hace
GOLD REPUTATION

PREMIUM DOCUMENTS. GREAT REVIEWS Many students don't have the time to work on their academic papers due to balancing with other responsibilities, for example, part-time work. I can relate. kindly don't hesitate to contact me, my study guides, notes and exams or test banks, are 100% graded

4.6

243 reseñas

5
210
4
9
3
9
2
0
1
15

Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes