Java Review Questions
Terms
undefined, object
copy deck
- The term "instance variable" is another name for
- non-static field.
- Real-world objects contain
- state and behavior
- software object's state is stored in
- fields
- A software object's behavior is exposed through
- methods
- Hiding internal data from the outside world, and accessing it only through publicly exposed methods is known as
- data encapsulation
- A blueprint for a software object is called a
- Class
- ommon behavior can be defined in a ____ and inherited into a ____ using the _____ keyword.
- Superclass, subclass, extends
- A collection of methods with no implementation is called an
- interface
- A namespace that organizes classes and interfaces by functionality is called a
- package
- The term API stands for
- Application Programming Interface.
- The term "class variable" is another name for
- static field
- A local variable sores temporary state; it is declared inside a
- method.
- A variable declared within the opening and closing parenthesis of a method is called a
- parameter.
- What are the eight primitive data types supported by the Java programming language?
- byte, short, int, long, float, double, boolean, char
- haracter strings are represented by the class
- java.lang.String
- An _____ is a container object that holds a fixed number of values of a single type.
- array
-
Consider the following code snippet:
arrayOfInts[j] > arrayOfInts[j+1]
Question: What operators does the code contain? - Answer: >, +
-
Consider the following code snippet:
int i = 10;
int n = i++%5;
1. Question: What are the values of i and n after the code is executed? - Answer: i is 11, and n is 0.
-
Consider the following code snippet:
int i = 10;
int n = i++%5;
2. Question: What are the final values of i and n if instead of using the postfix increment operator (i++), you use the prefix version (++i))? - Answer: i is 11, and n is 1.
- Question: To invert the value of a boolean, which operator would you use?
- Answer: The logical complement operator "!".
- Question: Which operator is used to compare two values, = or == ?
- Answer: The == operator is used for comparison, and = is used for assignment.
- Question: Explain the following code sample: result = someCondition ? value1 : value2;
- Answer: This code should be read as: "If someCondition is true, assign the value of value1 to result. Otherwise, assign the value of value2 to result."
- Operators may be used in building _______, which compute values.
- expressions