Java Flashcards

1
Q

What is an identifier?

A

A letter followed by any number of letters and numbers, case sensitive, that are used to identify classes, variables, methods, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a name?

A

A series of identifiers separated by a dot (.) such as, “System.out”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Java bytecode

A

A Java compiler translates Java source code into Java bytecode to be used by the Java interpreter to execute it on a specific machine. (Unlike machine code, Java bytecode is not tied to a particular processor.)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Problem Solving Steps

A
  1. Understand the problem.
  2. Design a solution.
  3. Consider alternatives to the solution and refine the solution.
  4. Implement the solution.
  5. Test the solution and fix any problems that exist.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Software Development Activities

A
  1. Establish the requirements.
  2. Creating a design.
  3. Implementing the design.
  4. Testing.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

object

A

A fundmental element in a program. Every object has:

  1. A state or state of being - as in the fundamental characteristics that currently define the object.
  2. A set of behaviors - The activities associated with the object.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

attributes

A

The values the object stores internally, which may represent primitive data or other objects. Collectively, the values of an object’s attributes define its current state.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

method

A

A group of programing statements that have been given a name.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

class

A

An object is defined by a class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

encapsulation

A

An object that protects and manages its own information. An object that is self-governing.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

inheritance

A

The definition of one class that is based on another class that already exists.

Common characteristics are defined in high-level classes, and specific differences are defined in derived classes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Polymorphism

A

We can refer to multiple types of related objects over time in consistent ways

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

System.out.print(“ “);

A

Prints the information between the parentheses to the screen and does not advance to the next line.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

System.out.println(“ “);

A

Prints the information between the parentheses to the screen and advance to the next line.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

string concatenation

A

The use of an operator to append one string to the end of another, such as:

“The only stupid question is “ + “the one that’s not asked.”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Escape Sequences

\b

A

backspace

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Escape Sequences

\t

A

tab

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Escape Sequences

\n

A

newline

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Escape Sequences

\r

A

carriage return

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Escape Sequences

"

A

double quote

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

Escape Sequences

'

A

single quote

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Escape Sequences

\

A

backslash

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

variable

A

A name for a location in memory used to hold a data value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

Local Variable Declaration

A

Consists of a Type followed by a list of variable names.

If the final modifier preceeds the declaration, the identifiers are declared as named constants whose values cannot be changed once they are set.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Q

assignment statement

A

Identifier = Expression;

total = 57;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
26
Q

Primitive Data Types

A
  1. four subsets of integers
    1. byte
    2. short
    3. int
    4. long
  2. two floating point data types
    1. float
    2. double
  3. character
  4. boolean
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
27
Q

byte

A

Storage: 8 bits

Min value: -128

Max value: 127

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

short

A

Storage: 16 bits

Min value: -32,768

Max value: 32,767

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

int

A

Storage: 32 bits

Min value: -2,147,483,648

Max value: 2,147,483,647

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

long

A

Storage: 64 bits

Min value: -9,223,372,036,854,775,808

Max value: 9,223,372,036,854,775,807

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

float

A

Storage: 32 bits

Min value: Approximately -3.4E+38

            with 7 significant digits

Max value: Approximately -3.4E+38

              with 7 significant digits
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q

constants

A

Identifiers similar to variables except that they hold a particular value for the duration of their existence. They should be in the form of:

final int MAX_OCCUPANCY = 427;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
33
Q

characters

A

A character literal is expressed in Java with single quotation characters, as in ‘b’ or ‘J’

Each character in a character set, such as ASCII has a number value that can be used in if statements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
34
Q

control characters

A

Nonprinting or invisible characters. Examples:

carriage return, null, and end-of-text marks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
35
Q

boolean

A

Only has two values: true and false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
36
Q

expression

A

A combination of one or more opperators and operands that usually perform a calculation. The value calculated does not have to be a number but often is.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
37
Q

Arithmetic operations

A

addition (+)

subtraction (-)

multiplication (*)

division (/)

remainder(%) - The result is the remainder of n/m in the form of n % m and has the sign of the numerator.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
38
Q

Operator Precedence

A

multiplication, division, and remainder have equal precidence and are performed before addition and subtraction.

Addition and subtraction have equal precidence.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
39
Q

Increment Operator

A

++

Adds 1 to any integer or floating point value

count++;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
40
Q

Decrement Operator

A

Subtracts 1 from any integer or floating point value

count–;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
41
Q

Assignment Operators

A

Examples:

total += 5; is the same as total = total + 5;

total -= 5; is the same as total = total - 5;

total *= 5; is the same as total = total * 5;

total /= 5; is the same as total = total / 5;

total %= 5; is the same as total = total % 5;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

Data Conversion

A

Converting a data value from one type to another type. However, the safest way is to go from a smaller data type to a larger one. If not, some bits are lost in the conversion.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
43
Q

Casting

A

A Java operator that is specified by a type name in parentheses:

dollars = (int) money;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

Scanner class

A

Part of the standard Java class library, provides convenient methods for reading input values of various types.

You must first create a Scanner** **object in order to invoke its methods.

Example:

Scanner scan = new Scanner (System.in);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
45
Q

Instantiation

(Objects)

A

Using the new opperator which returns the address of the new object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
46
Q

aliases

A

Two object designators that point to the same object.

String name1 = “Ada”;

String name2 = “Grace”;

name2 = name1;

Now name2 points to the same object as name1, which is “Ada”.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
47
Q

immutable

A

In reference to String object - Once created, the value cannot be lengthened or shortened, nor can any of its chararcters change.

When change, that object is no longer references and a new object is created. If not referenece by another designator, the object is no longer useable and is eventually elliminated by the automatic Java garbage collector.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

String (String str)

A

Constructor: creates a new string object with the same characteristics as str.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

char charAt (int index)

A

Returns the character at the specified index.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
50
Q

int compareTo (String str)

A

Returns an integer indicating if this string is lexically before (a negative return value) equal to (a zero return value), or lexically after (a positive return value), the string str.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
51
Q

String concat (String str)

A

Returns a new string consisting of this string concatenated with str.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
52
Q

boolean equals (String str)

A

Returns true if the string contains the same characters as str.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
53
Q

int lenght ()

A

Returns the # of characters in this string.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
54
Q

String replace (char oldChar, char newChar)

A

Returns a new string that is identical with the string except that every occurance of oldChar is replaced by newChar.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
55
Q

String substring (int offset, int endIndex)

A

Returns a new string that is a subset of this string starting at index offset and extending through endIndex-1.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
56
Q

String toLowerCase ()

A

Returns a new string identical to this string except all uppercase letters are converted to their lowercase equivalent.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
57
Q

String toUpperCase ()

A

Returns a new string identical to this string except all lowercase letters are converted to their uppcase equivalent.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
58
Q

import

A

Java keyword used to allow the program to use another class from within a particular class.

This can be done by package (import java.util.*;) or by a particular class within the package (import java.util.Random;).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
59
Q

static method

A

Also called class methods - They can be invoked through the name of the class in which they are defined, without having to instantiate an object of the class first.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
60
Q

NumberFormat Class (ordinal value)

A

The first value in an enumerated type has an ordinal value of 0, the second has a vaule of 1, and so on.

The ordinal method returns the numeric value associated with a particular enumerated type value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
61
Q

enumerated type

A

Establishes all possible values or a variable of that type by listing, ore enumerating, them.

Example:

enum Season {winter, spring, summer, fall};

Season time;

time = winter; (correct)

time = 10; (incorrect)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
62
Q

enumerated type (ordinal value)

A

The first value in an enumerated type has an ordinal value of 0, the second value has an ordinal value of 1, and so on. To get the ordinal value of an enumerated type, you can use the ordinal() method.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
63
Q

Wrapper Class

A

A class that represents a primitive type when you want to be able to treat a primitive data type as though it is an object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
64
Q

Autoboxing

A

The automatic conversion between a primitive value and a corresponding wraper object.

Interger obj1;

int num1 = 69;

obj1 = num1; // automatically creates an Integer object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
65
Q

Unboxing

A

The reverse of autoboxing, automatically converts a wrapper object into a corresponding primitive value.

Integer obj2 = new Integer(69);

int num2;

num2 = obj2; // automatically extracts the int value

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
66
Q

constructor

A

A special method that has the same name as the class and is called when an object is created to set up the object initially.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
67
Q

equality operators

A

== Test whether two values are equal

!= Test whether two values are not equal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
68
Q

relational operators

A

**> **greater than

< less than

>= greater than or equal to

<= less than or equal to

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
69
Q

logical operators

A

! logical NOT

&& logical AND

|| logical OR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
70
Q

precidence for arithmetic and logical opperators

A

arithmetice operators have a higher precidence than relational operators and therefore are performed before the logical operators.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
71
Q

if-else statement

A

Do one thing if, else do another.

if (height<= MAX)

 adjust = 0;

else

 adjust = MAX - height;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
72
Q

conditional operator

A

(total > MAX) ? total +1 : total * 2;

The entire conditional expression returns the value of the first expression if the condition is true, and returns the value of the second expression if the condition is false.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
73
Q

Nested if Statements

A

An if statement that is exicuted when another if statement is true.

if (x = 10)

 if (y \>2)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
74
Q

Comparing Floats

A

Rarely is == used.

A better way to check for a floating point equality is to compute the absolute value of the difference between the values and compare the result to some tolerace level.

if(Math.abs(f1-f2) < TOLERANCE)

 System.out.println("Essentially equal.");
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
75
Q

Comparing Characters

A

characters can be compared using equality and rational operators as their “value” is based on their Unicode character position and value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
76
Q

Comparing Strings

A

use .equals() to compare strings

if(name1.equals(name2);

Note:

(name1 == name2) tests to see if both references refer to the same object or in other words, have the same reference location.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
77
Q

Used to determine the relative ordering of two strings

A

compareTo()

name1.compareTo(name2);

Returns a negative value if name1 comes before name2.

Returns zero if name1 is the same as name2.

Returns a positive value if name1 comes after name2.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
78
Q

The switch Statement

A

Causes executing program to follow one of several paths based on a single value (Must be of type char, byte, short, or int).

switch (idChar)

{

 case 'A':

      aCount++;

      break;

 case 'B':

      aCount++;

      break;

and so on. If no case is match then continues on to the default case. Such as:

 default:

      noCaps++;

}

If no default is used, the program continues on with executing any of the switch statements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
79
Q

The while Statement

A

A loop that eveluates a boolean condition just as an if statment does and executes a statment repeatedly until the statement is nolonger true.

int count =1;

while (count <= 5)

{

 System.out.println(count);

 count++;

}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
80
Q

infinite loop

A

A conditional loop that does not become false and therefore continues to execute forever or until it is stopped.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
81
Q

Nested Loops

A

A loop inside of a loop.

int count 1 = 1, count2;

while (count1 <= 10){

 count2 = 1;

 while (count2 \<= 50){

       System.out.println("Here again");

      count2++;

      }

      count1++;

}

82
Q

iterator

A

An object that has methods that allow you to process a collection of items one at a time. An example is the Scanner class. All iterators have methods such as next() and hasnext().

83
Q

reading text files

A

fileScan = new Scanner(new File(“websites.inp”));

while (fileScan.hadNext()){

 url = fileScan.nextLine();

 System.out.printlin("URL: " + url);

}

84
Q

The do Statement

A

The do Statement is similar to the while statement in that it executes the loop body until a condition becomes false. However, unlike the while loop, the conditiona of a do loop is evaluated after the loop body executes. This ensures that it will happen at least once.

int count = 0;

do{

 count++;

 System.out.println(count);

}

while (count < 5);

85
Q

The for Statement

A

A repetition statement that is particularly well suited for executing the body of a loop a specific number of times.

for (int count = 1; count <= 5; count++)

 System.out.println(count);
86
Q

scope of a variable

A

The location at which a variable is declared defines its scope.

87
Q

instance data

A

Attributes that are reserved menory space every time an instance of the class is created.

Each object can store different values for its instance data.

88
Q

UML

A

Unified Modeling Language

89
Q

encapsulation

A

The characteristic of class such that is it difficult, if not impossible, for code outside of the class to “reach in” and change the value of a variable that is declared inside the class.

90
Q

modifier

A

A Java reserved word that is used to specify particular characteristics of a programing language construct.

91
Q

Visibility Modifiers

A
  • public - it can be directly referenced from outside the object.
    • Methods that provide services to the client must be declared public.
  • private - it can be used anyware inside the class deffinition but cannot be referenced externally.
    • Instance variables should be declared private.
  • protected - relevent only in the context of inheritance.
92
Q

Service methods

A

Methods of the class that are declared public and used to provide services to other classes.

93
Q

Support methods

A

Private methods that can only be used by the other methods of the class to perform a task.

94
Q

UML class diagram symbol for a public member

A

+, such as:

+ toString()

95
Q

UML class diagram symbol for a private member

A
  • , such as:
  • randInt()
96
Q

Accessor method

A

Another term for a getter, used to provide read-only access to a particular value.

getHeight();

97
Q

Mutator method

A

Another term for a setter, used to change a particular value.

setHeight();

98
Q

method declaration

A

Specifies the code executed when the method is invoked.

99
Q

header of a method

A

Includes the type of return value, the method name, and a list of parameters that the method accepts.

Example:

public int computeArea (int length, int width){

}

100
Q

driver programs

A

A program that has the sole purpose of driving the use of other, more interesting parts of other porgrams. Often used for testing purposes.

101
Q

The return Statement

A

The return type specified in the method header can be a primitive type, a class name, or the reserve word void.

102
Q

void

A

Used when a method does not return any value.

103
Q

return Statement Guidlines

A
  • A method that returns a value MUST have a return statement.
  • When a return statement is executed, control is immediately returned to the statement in the calling method.
  • A return statement consists of the reserved word return followed by an expression that didcated the value to be returned. The expression must be consistent with the return type specified in the method header.
  • A method that does not return a value usually does not contain a return statement.
  • It is usually not good practice to use more than one return statement in a method. It should be located at the end of the method unless do so will make the method overly complex.
104
Q

parameter

A

A value that is passed into a method when the method is invoked. Parameters provide data to a method that allow the method to do its job.

105
Q

parameter list

A

In the header of a method declaration, specifies the type of each value that is passed into the method, and the name by which the called method will refer to each value.

106
Q

formal parameters

A
  • The names of the parameters in the header of the method declaration.
  • Serve as variables inside the method and whose initial values come from the actual parameters in the invocation.
107
Q

local data

A
  • A variable declared inside a method.
  • Can not be referenced from outside the method.
108
Q

static method

A
  • A method that is invoked through its class name, instead of through an object of that class.
  • As in:
    • (static) dvd.getTitle(); vs.
    • dvd Matrix = new dvd(“Matrix”, 1999)
    • Matrix.getTitle();
109
Q

static variable

A
  • Sometimes called a *class variable, *is shared amoung all instances of a class.
  • Only one copy of a static variable for all objects.
  • Changing the value of a static variable in one object changes it for all of the objects.
  • Memory space is reserve regardless, even if it is never used.
  • Local variables cannot be static.
110
Q

dependency

A
  • One class relies on another.
  • A “uses” relationship.
  • Normally established when one class invokes one or more methods of another class.
111
Q

aggregation

A
  • When an object is made up other objects.
  • a “has-a” relationships
112
Q

aggregate object

A

Any object that contains references to other objects.

113
Q

this Reference

A
  • A reserve word in java.
  • It allows an object to refer to itself.
  • Often used to distinguish between a local variable and the variable with the same name that belongs to the particular object.
  • Often used to distinguish the parameters of a constructor from their corrisponding instance variables with the same names.
  • if (this.position == piece2.position) result = false:
114
Q

algorithm

A

A step-by-step process for solving a problem.

115
Q

method overloading

A

Using the same method name with different parameter lists for multiple methods.

116
Q

method’s signature

A

The method’s name, along with the number, type, and order of its parameters.

117
Q

inheritance

A
  • The process in which a new class is derived from an existing one.
  • The new class automatically contains the variables and methods in the original class.
  • To tailor the new class as needed, new variables and methods are added.
118
Q

parent class

A
  • Also know as a superclass, or base class.
  • The class used to derive a new class.
119
Q

child class

A
  • The new class derived from a parent class.
  • Also known as a subclass.
  • The child class “is-a” more specific version of the parent class.
120
Q

protected Modifier

A
  • Allows derived class to reference the variable or method from the parent class.
  • Allows the class to retain some encapsulation properties.
  • May be accessed by any class in the same package.
121
Q

super Reference

A
  • Can be used in a class to refer to the parent class.
  • Commonly used to invoke a parent classes constructor.
  • Example: super (numPages);
122
Q

overriding Methods

A

When a child class defines a method with the same name and signature as a method in the parent class.

123
Q

overloading Methods

A

A method in the child class that has the same name as a method in the parent class but a different signature.

124
Q

Abstract class

A
  • An abstract entity that is usually insuficiently defined to be used by itself.
  • Just like any other class, except that it may have some methods that have not been defined yet.
  • It is up to the child class to define these methods or it too will become an abstract class.
  • Not all methods need be undefined.
125
Q

Private members

A

Exist for an object of a derived class, even though they can’t be referenced directly.

126
Q

restricting inheritance (final)

A
  • Can be used to curtail the abilities related to inheritance.
  • A final method is often used on insist that particular functionality be used in all child classes.
  • A final class cannot be extended at all.
127
Q

Polymorphism

A

Having many forms

128
Q

Polymorphic reference

A

A reference variable that can refer to different types of objects at different points in time.

129
Q

Dynamic binding or late binding

A

The method definition that is used is determined by the type of the object being referenced.

130
Q

Binding

A

Tying a method invocation to a method definition.

131
Q

Interface

A
  • A collection of constants and abstract methods.
  • A class can implement multiple interfaces.
  • Example:
    • ​class ManyThings implements Interface1, Interface2, Interface 3
132
Q

Abstract method declaration

A

Methods must be declared with the same signatures as their abstract counterparts in the interface.

133
Q

Abstract/interface constants

A

An interface can contain constants defined using the final modifier that can be inherit as well.

134
Q

interface hierarchy

A
  • Inheritance relationships between interfaces similar to those for classes.
  • Class hierarchies and interface hierarchies do not overlap. That is, an interface cannot be used to derive a class, and a class cannot be used to derive an interface.
135
Q

Comparable Interface

A
  • Contains only the compareTo() method.
  • Takes an object as a parameter and returns an integer.
  • if(obj1.compareTo(obj2) < 0); System.out.println(“obj1 is less than obj2”);
  • int t = obj1.compareTo(obj2);
    • integer returned is:
      • obj1 < obj2, t = negative
      • obj1 = obj2, t = 0
      • obj1 > obj2, t = positive
      *
136
Q

Iterator Interface

A
  • Used by a class that represents a collection of objects, providing a means to move through the collection one object at a time.
  • The primary methods
    • hasNext();
      • returns true if yes
    • next();
      • returns the next object.
    • remove();
      • removes the object that was most recently returned by the next() method.
137
Q

cast an object into the appropriate reference

A

((Philosopher) specail).pontificate();

138
Q

Exception

A

An object that defines an unusual or erroneous situation.

139
Q

Error

A

Similar to an exception, except that an error generally represents an unrecoverable situation and should not be caught.

140
Q

try-catch Statement

A

Identifies a block of statements that may throw an exception.

141
Q

catch clause

A

Follows a try block and defines how a particular kind of exception is handled.Also called an exception handler

142
Q

exception handler

A

Follows a try block and defines how a particular kind of exception is handled.Also called a catch clause.

143
Q

finally clause

A

An optional end to a try-catch statement.Defines a section of code that is executed no matter how the try block is exited.

144
Q

exception propagation

A

If an exception is not caught and handled in the method where it occurs, control is immediately returned to the method that invoked the method that produced the exception. If it isn’t caught there, control returns to method that called it, and so on until it is passed out of the main method and then the program is terminated.

145
Q

Errors

A
  • LinkageError
  • ThreadDeath
  • VirtualMachineError
  • AWTError
146
Q

Exceptions

A
  • IllegalAccessException
  • NoSuchMethodException
  • ClassNotFoundException
147
Q

RuntimeExceptions

A
  • ArithmeticException
  • IndexOutOfBoundsException
  • NullPointerException
148
Q

checked exception

A

Must either be caught by a method or be listed in the throws clause of any method that may throw or propagate it.

149
Q

throws clause

A

Appended to the header of a method definition to formally acknowledge that the method will throw or propagate a particular exception if it occurs.

150
Q

unchecked exception

A

Requires no throws clause.The only unchecked exceptions in Java are objects of the type RuntimeException or any of its descendants:

  • ArithmeticException
  • IndexOutOfBoundsException
  • NullPointerException
151
Q

stream

A

An ordered sequence of bytes.

152
Q

input stream

A

From which we read information

153
Q

output stream

A

To whih we write information.

154
Q

Asymptotic complexity of an algorithm

A
  • The general nature of the function as n increases.
  • Also called the order of the algorithm
  • Not affected by constants
155
Q

dominant term

A

The term that increases most quickly as n increases.

156
Q

order of an algorithm

A
  • The general nature of the function as n increases.
  • Also called the Asymptotic complexity of the algorithm
  • Not affected by constants
157
Q

Determining Time Complexity - Loops

A

Loops have a time complexity of O(n).

158
Q

Determining Time Complexity - Nested Loops

A

Nested loops have a time complexity of O(nx). Where x is the number of loops in the nest. The follow example would be O(n3):

  • for (int count = 0; count < n; count++){
  • for(int count2 = 0; count < n; count2++){
  • for(int count3 = 0; count < n; count3++){
  • /* some sequence of O(1) steps */
  • }
  • }
159
Q

Determining Time Complexity - Method Calls

A

The order of method calls must be determined before the order of the code segment calling the method can be determined.

Once you have the method complexity, multiply this by the # of times the loop will execute.

160
Q

collection

A

An object that gathers and organizes other objects.

It defines the specific ways in which those objects can be accessed and managed.

The user of a collection, which is usually another class or object in the software system, must interact with the collection only in the prescribed ways.

161
Q

elements

A

The objects inside of a collection.

162
Q

Collection categories

A

linear & nonlinear

163
Q

linear collection

A

A collection in which the elements of the collection are organized in a straight line.

164
Q

nonlinear collection

A

A collection in which the elements are organized in something other than a straight line, such as a hierarchy or a network or no organization at all.

165
Q

The organization of the elements in a collection, relative to each other, is usually determined by one of two things:

A
  • The order in which they were added to the collection.
  • Some inherent relationship among the elements themselves.
166
Q

Exception

A

An object that defines an unusual or erroneous situation.

167
Q

Error

A

Similar to an exception, except that an error generally represents an unrecoverable situation and should not be caught.

168
Q

try-catch Statement

A

Identifies a block of statements that may throw an exception.

169
Q

catch clause

A

Follows a try block and defines how a particular kind of exception is handled.Also called an exception handler

170
Q

exception handler

A

Follows a try block and defines how a particular kind of exception is handled.Also called a catch clause.

171
Q

finally clause

A

An optional end to a try-catch statement.Defines a section of code that is executed no matter how the try block is exited.

172
Q

exception propagation

A

If an exception is not caught and handled in the method where it occurs, control is immediately returned to the method that invoked the method that produced the exception. If it isn’t caught there, control returns to method that called it, and so on until it is passed out of the main method and then the program is terminated.

173
Q

Errors

A

LinkageErrorThreadDeathVirtualMachineErrorAWTError

174
Q

Exceptions

A

IllegalAccessExceptionNoSuchMethodExceptionClassNotFoundException

175
Q

RuntimeExceptions

A

ArithmeticExceptionIndexOutOfBoundsExceptionNullPointerException

176
Q

checked exception

A

Must either be caught by a method or be listed in the throws clause of any method that may throw or propagate it.

177
Q

throws clause

A

Appended to the header of a method definition to formally acknowledge that the method will throw or propagate a particular exception if it occurs.

178
Q

unchecked exception

A

Requires no throws clause.The only unchecked exceptions in Java are objects of the type RuntimeException or any of its descendants:ArithmeticExceptionIndexOutOfBoundsExceptionNullPointerException

179
Q

Abstraction

A

Hides certain data types at certain times.

180
Q

Data Type

A

A group of values and the operations defined on those values.

181
Q

ADT

A

Abstract Data Type: A data type whose values and operation are not inherently defined within a programming language.It is abstract only in that the details of its implementation must be defined and should be hidden from the user.

182
Q

data structure

A

The collection of programming constructs used to implement a collection.

183
Q

API

A

Application Programming Interfaces: A set of classes that represent a few specific types of collections, implemented in various ways.

184
Q

Stack

A

A linear collection whose elements are added to, and removed from, the same end.Last in, first out

185
Q

Stack: push

A

Adds an element to the top of the stack.

186
Q

Stack: pop

A

Removes an element from the top of the stack.

187
Q

Stack: peek

A

Examines the elements at the top of the stack.

188
Q

Stack: isEmpty

A

Determines if the stack is empty.

189
Q

Stack: size

A

Determines the # of elements on the stack

190
Q

Exception

A

An object that defines an unusual or erroneous situation.

191
Q

To expand an array size:

A

private void expandCapacity(){ stack = Arrays.copyOf (stack, stack.length * 2);}

192
Q

liinked structure

A

A data structure that uses object reference variables to create links between objects.

The primary alternative to an array-based implemenation of a collection.

193
Q

self-referential object

A

One object contains a link to a second object which contains a link to another object which contains a link to another and so on.

194
Q

linked list

A

A linked structure in which one object refers to the next, creating a linear ordering of the objects in the list.

A dynamic structure - its size grows and shrinks as needed to accomodate the number of elements stored.

195
Q

nodes

A

The term that is often used to refer to the objects stored in a linked list.

196
Q

dynamic structure

A

A data structured the grows and shrinks in size as needed to accomodate the number of elements stored.

197
Q

Accessing elements in a linked list

A

The only way to access the elements in a linked list is to start with the first element and progress through the list.

198
Q

recursion

A

A process whereby a method calls itself either dirrectly or indirectly.

199
Q

program stack

A
  • Also known as a run-time stack, is used to keep track of methods that are invoked.
  • Every time a method is called, an activation record that represents the invocation is created and pushed onto the program stack.
  • Therefore, the elements on the stack represent the series of method invocations that occurred to reach a particular point in an executing program
200
Q

call stack trace

A

A call that indicates what method a problem occured within and what method calls were made to arrive at that point.

201
Q
A