1/16
These flashcards cover key concepts related to mathematical functions, characters, and strings in Java, as taught in CIS 103 Programming Fundamentals I.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is the purpose of the Math class in Java?
To provide useful methods for performing common mathematical functions.
What method returns the square root of a number in Java?
Math.sqrt(double a)
What does the method Math.pow(a, b) return?
Returns a raised to the power of b.
What is the value returned by Math.ceil(2.1)?
3.0
What character data type represents a single character in Java?
char
How do you denote a character literal in Java?
A character literal is enclosed in single quotation marks, e.g., 'A'.
What does the escape sequence '\n' represent?
Linefeed (new line).
What is the purpose of the equals() method for strings in Java?
To compare if two strings are equal.
What Java class allows you to manipulate strings?
String class.
What is the returned value of message.length() for String message = "Hello"?
5
What method is used to concatenate two strings in Java?
concat(s1) or the + operator.
What does the method charAt(index) do?
Returns the character at the specified index from this string.
What does the method indexOf(ch) return?
Returns the index of the first occurrence of ch in the string.
What does the method Math.random() return?
A random double value in the range [0.0, 1.0[.
What does the sprintf method do in Java?
Formats output based on format specifiers.
How do you declare a string in Java?
Using the String data type, e.g., String message = "Welcome".
How is Unicode represented in Java?
Using a 16-bit encoding scheme preceded by \u, expressed in four hexadecimal digits.