Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Document preview thumbnail
Vista previa 2 fuera de 5 páginas
Examen

CS302 EXAM 1 QUESTIONS WITH CORRECT ANSWERS 100% VERIFIED| GUARANTEED SUCCESS

Document preview thumbnail
Vista previa 2 fuera de 5 páginas

CS302 EXAM 1 QUESTIONS WITH CORRECT ANSWERS 100% VERIFIED| GUARANTEED SUCCESS

Vista previa del contenido

CS302 EXAM 1 QUESTIONS WITH CORRECT ANSWERS 100% VERIFIED| GUARANTEED SUCCESS



given: String[] list = {"a", "b", "c"} ; i = 0;

what does list.length vs. list[i].length() return? Array.length is a property of arrays that
returns the number of elements in an array so list.length returns 3

String.length() is a method of strings that returns the number of characters in a string, and
because 'list' is a string type array, list[i].length() returns the number of characters at index i in
array list so returns 1 ("a" = 1 char)



return type of Math.pow(x, y) double



algorithms a step-by-step set of operations to be performed

- procedure for solving a problem in terms of the actions to be executed and the order in which
those actions are to be executed.

- sequence of steps taken to solve a problem



abstraction a technique for managing complexity



escape sequences special character sequences used within a string

- starts with \

- within " "

\n = newline

\t = tab

\' = '

\" = "

\\ = \

, variables name areas of computer memory, declare before use, declare type of data,
initialize



= vs. == = : assignment, assigns values on right to variable on left

== : conventional definition of equals, or "is"



read in values 1. import java.util.Scanner; // imports scanner

2. Scanner input = new Scanner(System.in); // enables scanner to read input from System.in

3. int variable = input.nextInt(); // scanner reads next int from System.in

String name = input.nextLine(); // scanner reads next line of input, next string



~same as~

Scanner scnr = new Scanner(System.in);

int variable = scnr.nextInt();

String name = scnr.nextLine();



.nextLine() vs .next() both used to get next string from input, however -

.next() reads up to the first whitespace(space, newline, tab, or user press ENTER), reads first
non-whitespace thing

-- works when input is one word or when only want first word of input

-- places cursor(scanner) on same line where left off --> if used again, tosses the whitespace it
stopped at and returns next non-whitespace thing

- x = scnr.next()

x.equals("\n") WILL NEVER HAPPEN, scnr.next CANNOT be "\n"

if user input looks like:

1

G

Información del documento

Subido en
12 de mayo de 2025
Número de páginas
5
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas
$11.99

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

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.
DrJon
3.8
(160)
Vendido
585
Seguidores
188
Artículos
20922
Última venta
5 días hace



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