• 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/41

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;

41 Cards in this Set

  • Front
  • Back
What is a fundamental way to handle complexity?
Use abstractions: it denotes the essential properties and behaviors of an object to differentiate it from other objects. The hard part is to find the right abstraction.
What is a class?
It's a blueprint for creating objects (or abstractions of the real world)
What is the process of creating objects from a class?
Instantiation / an object is an instance of a class
What is an object reference?
A variable that can store a reference value to an instantiated object
What's the only way to manipulate an object in java?
Through its reference value
Can you refer to an object with multiple references?
Yes, they are called aliases (CharStack a=new CharStack; CharStack b=a;)
What happens when there are no more references to an object?
The automatic garbage collector can run, so the memory can be reclaimed and reallocated
Does each created object get its own copies of fields?
Yes. They are called instance variables and they comprise the object's state.
What defines an object's state?
The values of its instance variables (if two objects have the same values, they have the same state)
What defines an object's behavior?
Its methods
How do objects communicate?
By message passing (i.e., invoking each other's methods)
What is the "dot" in a method call called?
The "binary infix dot" operator, but the "dot" operator can also be used to reference fields of an object
What is an "instance member"
They are both instance variables and instance methods of an object. They can only be accessed or invoked through an object reference.
What is an "instance variable"
A field that is allocated when the class if instantiated (i.e., when an object of the class is created). It's also called a non-static field.
What is an "instance method"?
A method that belongs to an instance of the class. Objects of the same class share its implementation.
What is a "static member"? How can they be accessed?
These are both static variables and static methods of a class. They can be accessed or invoked either by using the class name or through an object reference.
What is a "static variable"? When is it allocated?
A field that is allocated when the class is loaded. It belongs to the class and not to any specific object of the class. It's also called a static field or a class variable?
What is a "static method"?
A method that belongs to the class, and not to any object of the class. It's also called a class method.
What are the two funadamental mechanisms to build a new class from an existing one?
(1) Inheritance and (2) aggregation (i.e., a composite object)
When does it make sense to model a new class with inheritance?
When the new class will inherit all the properties of the parent class. In other words, the child class is going to be a more SPECIALIZED version of the parent class.
When does it make sense to model a new class with aggregation?
When the new class is comprised of multiple different classes
What are the key terms in inheritance?
The child class is called the subclass, and the parent class is the superclass. The subclass EXTENDS the superclass.
How does Java support aggregate objects?
By reference. I.e., you have to create reference variables to the constituent objects
What are the two different types of values in Java?
There are (1) reference variables that hold references to instances of classes and there are (2) atomic values of primitive data types.
Can objects in Java contain other objects?
Only by holding references to other values (i.e., reference values)
How many objects can you have in a .java file?
As many as you want except that each public class must have its own .java file
What is a lexical token?
The low-level language elements that form the building blocks for more complex constructs. Identifiers, numbers, operators, and special characters are examples of tokens that can be used to contract high-level constructs like expressions, statements, methods, and classes.
What is an identifier?
A name in a program: identifiers can be used to denote classes, methods, variables, and labels. In Java, an identifier is composed of a sequence of characters, where each character can be either a letter or digit. The first character has to be a letter.
Can you use a currency symbol or underscore as the first letter of an identifier in Java?
Sure, but you should probably avoid it
Can use an @ symbol in an identifier?
No
What is a keyword?
It's a reserved word that's already predefined in the language and you can't use it to denote other entities.
What is a literal?
It denotes a constant value (i.e., a value that remains unchanged in the program). Examples are 2000, 0, -7, 3.14, 'a', true, "abba", and null
What's the default data type of a literal?
It's going to be an int unless you specify it as a different type (like a long by using L as a suffix)
What's the default data type of a floating point?
Double unless you tell it to be a float with "F"
What are the three categories of primitive data types in java?
Integrals: signed integers (byte, short, int, long) and unsigned character values; floating point types: float, double; and boolean types
Is a primitive data type an object?
No, but there are wrapper classes that you can use
How wide is the float and the double?
The float is 32 bits wide, the double is 64 bits wide
What's the difference between default values in fields and methods?
The values of fields are set automatically and you don't need to initialize them. They values for local fields of local methods are not, however. The compiler reports an error if you try to compile them without initialized values.
Discuss the lifetime of a variable
Its lifetime depends on the context in which it was declared. It's also referred to as its scope. I.e., if it's an instance of an object, or a static variable, or local to a method, construct, or block.
What was the idea behind the JavaBeans standard?
It would like reusable software components be modelled in Java. Especially with builder tools that could take advantage of the components.
What are some of the key naming patterns in JavaBeans?
The properties of the object should be private, and they should start with a lower case letter. You should wrap them with getter and setter methods.