1/15
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
What data type do Java strings represent?
Strings are composed of characters (char), which is a primitive type.
What does the method length() do for strings in Java?
Returns the total number of characters in the string.
What does the substring(int from, int to) method return?
Returns a new string starting at index 'from' and ending just before index 'to' (to is exclusive).
What will the indexOf(String str) method return if 'str' is not found in the string?
Returns -1.
What does the equals(String other) method do?
Checks if two strings contain the same characters in the same order.
What is the purpose of the Math class in Java?
Provides static methods for common mathematical calculations.
What does the static method abs(int x) return?
Returns the absolute value of the integer x.
What does the static method random() return in the Math class?
Returns a random double in the range [0.0,1.0).
What is the significance of zero-based indexing in Java strings?
The first character is at index 0, and the last character is at index length()-1.
How does the max(int a, int b) method behave?
Returns the larger of two values.
What type of values can be stored in an ArrayList?
ArrayLists can store multiple types if the type isn鈥檛 specified.
What happens if you try to access an index less than 0 or greater than or equal to length() of a string?
It will throw a StringIndexOutOfBoundsException.
What does the compareTo(String other) method do?
Compares strings lexicographically and returns an integer indicating their relative order.
What does substring(int from) return?
Returns a new string starting at index 'from' and going to the end of the string.
How can you concatenate two strings in Java?
Using the + operator to join strings or a string and a primitive.
What is a key feature of arrays in Java regarding size?
The size of arrays cannot be changed after they are created.