click below
click below
Normal Size Small Size show me how
SCJA-drills-chap03
Question | Answer |
---|---|
Which compound assignment operators are covered on the exam? | The exam covers the following assignment and compound assignment operators: =, +=, and -=. |
What does = do? What is it called? | The assignment operator (=) assigns values to variables. |
What is the additional compound assignment operator used for? | The additional compound assignment operator is used for shorthand. As such, a=a+b is written a+=b. |
What is the subtraction compound assignment operator used for? | The subtraction compound assignment operator is used for shorthand. As such, a=a-b is written a-=b. |
Which arithmetic operators are covered on the exam? | The exam covers the following arithmetic operators: +, -, *, /, %, ++, and --. |
What does + do? What is it called? | The addition operation (+) is used to add two operands together. |
What does - do? What is it called? | The subtraction operator (-) is used to subtract the right operand from the left operand. |
What does * do? What is it called? | The multiplication operator (*) is used to multiply two operands together. |
What does / do? What is it called? | The divisor operator (/) is used to divide the right operand into the left operand. |
What does % do? What is it called? | The modulus operator (%) returns the remainder of a division. |
What does the prefix increment do? | The prefix increment (++) and prefix decrement (--) operators are used to increment or decrement a value before it is used in an expression. |
What does the postfix increment do? | The postfix increment (++) and postfix decrement (--) operators are used to increment or decrement a value after it is used in an expression. |
Which relational operators are covered on the exam? | The exam covers the following relational operators: <, <=, >, >=, ==, and !=. |
What does < do? What is it called? | The “less than” operator (<) returns true if the left operand is less than the right operand. |
What does <= do? What is it called? | The “less than or equal to” operator (<=) returns true if the left operand is less than or equal to the right operand. |
What does > do? What is it called? | The “greater than” operator (>) returns true if the right operand is less than the left operand. |
What does >= do? What is it called? | The “greater than or equal to” operator (>=) returns true if the right operand is less than or equal to the left operand. |
What does == do? What is it called? | The “equal to” equality operator (==) returns true if the left operand is equal to the right operand. |
What does != do? What is it called? | The “not equal to” equality operator (!=) returns true if the left operand is not equal to the right operand. |
What can equality operators test? | Equality operators can test numbers, characters, Booleans, and reference variables. |
Which logical operators are covered on the exam? | The exam covers the following logical operators: !, &&, and ||. |
What does ! do? What is it called? | The logical negation (inversion) operator (!) negates the value of the boolean operand. |
What does && do? What is it called? | The logical AND (conditional AND) operator (&&) returns true if both operands are true. |
Which "interesting feature" does the logical AND have? | The logical AND operator is known as a short-circuit operator because it does not evaluate the right operand if the left operand is false. |
What does || do? What is it called? | The logical OR (conditional OR) operator (||) returns true if either operand is true. |
Which "interesting feature" does the logical AND have? | The conditional OR operator is known as a short-circuit operator because it does not evaluate the right operand if the left operand is true. |
What is an object of the String class? | An object of the String class represents an immutable character string. |
What does an object of the StringBuilder class represent? | An object of the StringBuilder class represents a mutable character string. |
What does an object of the StringBuffer class represent? | An object of the StringBuffer class represents a thread-safe mutable character string. |
What does mutable mean? How does it apply to Java? | Mutable means “changeable.” Note that Java variables such as primitives are mutable by default and can be made immutable by using the final keyword. |
Give three classes which implement the CharSequence interface. | The CharSequence interface is implemented by the String, StringBuilder, and StringBuffer classes. It can be used as an argument in the String class’s replace method. |
What is the + operator in relation to String? What does it do? | The string concatenation operator (+) joins two strings together. |
What is the behaviour of the string concatenation operator joins two operands together? | The string concatenation operator will join two operands together, as long as one or both of them are strings. |
What does the String class's charAt method return? | The String class’s charAt method returns a primitive char value from a specified int index value in relationship to the referenced string. |
What does the String class's indexOf method return? | The String class’s indexOf methods returns a primitive int value representing the index of a character or string in relationship to the referenced string. |
What does the String class's length method return? | The String class’s length method returns a primitive int value representing the length of the referenced string. |
What does the String class's replace method return? | The String class’s replace methods return strings replacing all characters or strings in relationship to the referenced string. |
What does the String class's startsWith method return? | The String class’s startsWith method returns a primitive boolean value representing the results of a test to see if the supplied prefix starts the referenced string. |
What does the String class's endsWith method return? | The String class’s endsWith method returns a primitive boolean value representing the results of a test to see if the supplied suffix ends the referenced string. |
What does the String class's substring method return? | The String class’s substring methods return new strings that are substrings of the referenced string. |
What does the String class's trim method return? | The String class’s trim method returns the entire string minus leading and trailing whitespace characters in relationship to the referenced string. |