Home > Preview
The flashcards below were created by user
on FreezingBlue Flashcards.
Member variables in a class are called _____.
Variables in a method or block of code are called _____.
Variables in method declarations are called _____.
'public' and 'private' are two examples of what?
The Java programming language defines what types of variables?
- 1. Instance Variables (Non-Static Fields)
- 2. Class Variables (Static Fields)
- 3. Local Variables
- 4. Parameters
Non-static fields are also known as _____, because _____.
instance variables, because their values are unique to each instance of a class (so, for instance, the weight of once bicycle is never exactly the same as the weight of another).
Non-static fields are declared without what?
The static keyword.
A class variable is any field declared with what?
The static modifier.
What does the static modifer tell the compiler about a field? What does the keyword final tell the compiler?
Static tells the compiler that there is only one copy of this variable in existence -- no matter how many instances of the class there are. So, for the class 'bicycle', all instances would have two wheels. The keyword final tells the compiler that this value will never change.
Which two of the following are not keywords?
There is no special keyword designating a variable as local; that determination comes entirely from the location in which the variable is declared — which is between the opening and closing braces of _____.
Parameters are always classified as _____ not _____.
variables, not fields
Variable names are case sensitive. True or false?
The convention is always to begin your variable names with a _____, not a _____ or a _____.
The convention is always to begin your variable names with a letter, not a '$' or a '_'.
Which of the variable names below do not follow convention?
- house_number -- shouldn't have underscore
- BrandName -- should be 'brandName'
If your variable stores a constant value, what is the naming convention?
All caps, words separated by an underscore. The underscore isn't used anywhere else.
So, an example would be:
static final int WOOD_CHUCKED = 7
Java is statically typed. What does this mean?
All variables must be declared before they can be used.
What is a primitive data type?
A data type that is pre-defined by the language and is named with reserved keyword.
How many primitive data types does Java support? What are they?
Which uninitialized field/variable below is not assigned a default value by the compiler?
A _____ is a source code representation of a fixed value and does not require computation before being used in your code.
An integer literal is of the type _____ if it ends with the character _____; otherwise, it is of the type _____.
An integer literal is of the type Long if it ends with the character 'L' (or 'l' -- though it is recommended you always use the upper case since the lower is easy to mistake for the digit '1'); otherwise, it is of the type int.
What is the prefix used in Java for hexadecimal values? Binary?
- Hexidecimal prefix: '0x'
- Binary prefix: '0b'
A floating-point literal is of type _____ if it ends with the letter _____ or _____; otherwise its type is _____ and it can optionally end with the letter _____ or _____.
A floating-point literal is of type float if it ends with the letter F or f; otherwise its type is double and it can optionally end with the letter D or d.
Always use 'single quotes' for _____ literals and "double quotes" for _____ literals.
Always use 'single quotes' for char literals and "double quotes" for String literals.
There's a special kind of literal called a class literal, formed by _____. This refers to _____.
There's a special kind of literal called a class literal, formed by taking a type name and appending ".class"; for example, String.class. This refers to the object (of type Class) that represents the type itself.
After a method throws an exception, the runtime system attempts to find something to handle it. The set of possible "somethings" to handle the exception is the ordered list of methods that had been called to get to the method where the error occurred. The list of methods is known as the _____.
What happens when the system can't find an exception handler to catch an exception?
The runtime system (and, consequently, the program) terminates.
Valid Java programming language code must honor the _____. This means that code that might throw certain exceptions must be enclosed by what?
Catch or Specify Requirement
- This means that code that might thow certain exceptions must be enclosed by either of the following:
- 1. A "try" statement that catches the exception. The try must provide a dhandler for the exception.
- 2. A method that specifies that it can throw the exception. The method must provide a throws clause that lists the exception.
What are the three types of exceptions?
- Checked Exception
- Runtime Exception