Java Interview Questions

¡Supera tus tareas y exámenes ahora con Quizwiz!

what does a substring() do? If I format it substring(x, y), what are the x and y representing?

A substring takes a full string and makes it shorter. x is the start index and y is the end index.

Using a loop, how do you reverse a string in java?

Declare empty String, iterate over an array using a for loop from last to 0th index, and add character to the declared string while iterating.

when can an if statement dismiss curly braces?

when there is only one statement following

What are the three pieces of a for loop? Include an example in parentheses

initialization (i=0), condition (i >= 0) and advancement (i++ or i--)

what is indexOf() used for, and what is returned if an index is not found?

it is used to find the index of a desired character. the value -1 is returned if an index is not found.

What is .isEmpty()/what does it mean?

it returns true if a string has a length of 0


Conjuntos de estudio relacionados

Chapter 15 Autonomic Nervous System

View Set

Econ 2301 Ch. 7 Midterm Review Lee College Mrs. Kar

View Set

MedSurg Final, adv. medsurg FINAL

View Set

Chapter 8. Configuring Networking

View Set

AP GOV civil liberties and rights test

View Set