• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/56

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

56 Cards in this Set

  • Front
  • Back
8 Different primitive types in java
boolean, int, float, long, double, byte, char, short
When are primitive values initialized?
When declared globally but not locally
Good Practice - When writing floats or longs in the program it is good to write ____
L after longs and f after floats
Hierarchy of primitive types
Double
Float
Long
Int
Short - Char
Byte

Boolean
Widening
Casting from a type lower on the hierarchy to a type higher than. (Implicit but can be type casted)
Narrowing
Casting from a type higher on the hierarchy to a type lower than.
(Requires an explicit cast and can cause a loss of information)
A variable is the name of a ______ that holds a ________
Memory location, Value
Declaration ______ the variable name to a _________
binds, memory location
assignment _________ contents of memory
copies
Parameters are ________
copies
Examples of reference types
User created classes, arrays, Integer, Long, Double, Java provided classes
For reference types, the _______ in the memory location is a _________ to the actual object
value, pointer
Assignment of a reference copies the __________
pointer
Parameter passing for a reference copies the ________
pointer
IDE
integrated development environment
State of an object
Data the object holds
Behavior of an object
how state changes
Each object is an _________ of a class
instance
Fields
data that determine the state of the object, i.e. variables
Methods
procedures that access/modify the state of the object
Private members
can be accessed only by instances of the same class
Public members
can be accessed by any object
Static Members
Allow all instances of a class to access one shared piece of data. However, can not access instance members.
How are constants declared
with the final keyword
What is a package
A grouping of classes
What does a package provide
1.) Logical structuring, related classes are bundled
2.) encapsulation - another level of class control
3.) Distinct namespace
What is the naming convention for a package
Reverse of companies domain name

www.cse.ohio-state.edu

goes to

edu.ohio-state.cse
What is the purpose of a static initialization block
To initialize a static variable. However, it can only modify static variables.
What is an interface
A set of requirements that describes what a class should do and describe how they should do it
Requirements/Constraints of an interface
1.) Must be declared public interface
2.) Methods have no bodies
3.) No constructors provided
4.) Can only have static variables
Interfaces should provide
1.) Method signatures
2.) Mathematical Model
3.) Constraints (Invariants)
4.) Method specifications
Declared Type
Object whose type is declared at compile time
Dynamic Type
Object whose type is declared at run time
What does coding to the interface mean
All declared types are types of the interface
Classes should provide
1.) Concrete representation of the object
Accessor Method
A method that reads, but never changes, the state of an object.

ex. getter methods
Mutator Method
A method that modifies the state of an object

ex. setter methods
Steps to take when making a defensive copy of a constructor argument
1.) copy the arguments
2.) Check the validity of the arguments
Immutability
An object whose abstract value can never be changed, no mutator methods
Steps to write an immutable class
1.) Write an immutable interface
2.) Make all fields private
3.) Ensure exclusive access to any mutable objects referred to by fields
When declaring an immutable class declare it to be ________
final
Review JUNIT
DO IT
T is called what
Naked Type
Interface Box<T>

What is Box called
raw type
Comparable is used for what and what are the 3 requirements for a good comparable method
Compare the natural ordering of items in a class

1.) Antisymmetric
2.) Transitive
3.) Reflexive
What would comparable return for the following:

x = 5
y = 10
z = 10

1.) x < y
2.) y > x
3.) y = x
1.) -1
2.) 1
3.) 0
What does extending an interface mean
An interface can extend another and receives all methods declared in interfaces above
Subinterfaces are ______ types than superinterfaces
smaller
Behavior Subtype
A class 'x' is a behavioral subtype of a class 'y' if 'x' can do everything 'y' can and potentially more
3 requirements for behavioral subtyping
1.) invariant is stronger
2.) methods require less
3.) methods ensure more
What kind of inheritance does java have
Single inheritance
What does a subclass inherent from its superclass
all members that aren't private and does not get constructors
what does the final keyword on a class do
prevent another class from extending it
Protected
signifies that the method or variable can only be accessed by elements residing in its class, subclasses, or classes in the same package.
Abstract classes are different from interfaces how
1.) Allows for constructors
2.) Static methods
3.) Fields
4.) Visibilities
5.) Implementations
Static methods in inherited classes
Static methods are not inherited