Java Fundamentals Flashcards

1
Q

Class

A

A programmer-defined data type; a template for creating objects.

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

Object

A

An instance of a class

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

Variable

A

A user defined memory location. This is akin to referring to a physical location as Empire State Building instead of 20 W 34th St, New York, NY 10001.

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

Methods

A

The actions performed by an object. They are comprised of a sequence of statements that has a name, may have parameter variables, and may return a value. A method can be invoked any number of times, with different values for its parameter variables.

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

Initialize

A

Set a variable to a well-defined value when it is created.

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

Assignment

A

Placing a new value into a variable.

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

Case sensitive

A

Distinguishing upper- and lowercase characters. Java is a case sensitive language.

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

Reserved words

A

A word that has a special meaning in a programming language and therefore cannot be used as a name by the programmer.

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

Comments

A

An explanation to help the human reader understand a section of a program; ignored by the compiler.

There are two main types:

  1. JavaDoc comments - These can be read by someone separately from the code (can also be used for multi-line comments) and are expected to be present before each Class definition and method header.
    /**
    * This is a JavaDoc comment
    */
  2. Internal comments - These are only read in the code and are typically used for single line comments.
    // This is an internal comment
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

uninitialized variable

A

A variable that has not been set to a particular value. In Java, using an uninitialized local variable is a syntax error.

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

Public interface

A

The features (methods, variables, and nested types) of a class that are accessible to all clients.

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

argument

A

A value supplied in a method call, or one of the values combined by an operator.

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

void

A

A reserved word indicating no return type or an unknown type.

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

Overloading

A

Giving more than one meaning to a method name.

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

Accessor method

A

A method that accesses an object and returns some information about it, but does not change it. For example, the length method of the String class is an accessor method since it returns the length of the string without modifying it. Similarly, “getter” methods are also accessor methods since they return information without changing any data.

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

mutator method

A

A method that changes the state of an object.

17
Q

API documentation

A

Information about each class in the Java library.

18
Q

Packages

A

A collection of related classes. The import statement is used to access one or more classes in a package.

19
Q

Object reference

A

A value that denotes the location of an object in memory. In Java, a variable whose type is a class contains a reference to an object of that class.

20
Q

Inner class

A

A class that is defined inside another class.

21
Q

Literal

A

A value that is written into the code of the program

22
Q

Self-documenting programs

A

Programs that can be understood just be reading their code. Clearly naming variables is one way to do this.

23
Q

Statically typed language

A

Java is a statically typed language which means that anytime you use a variable you need to tell the computer what type of data you’ll be storing in that variable.

24
Q

Named constants

A

A value that cannot be changed by a program. In Java, constants are defined with the reserved word final. It is convention to write such variable names in all uppercase letters.
For example:
final double INTEREST_RATE = 0.069;

25
Q

prompt

A

A string that tells the user to provide input.

26
Q

string

A

A sequence of characters.

27
Q

literals

A

A notation for a fixed value in a program, such as –2, 3.14, 6.02214115E23, “Harry”, or ‘H’.

28
Q

Unicode

A

A standard code that assigns code values consisting of two bytes to characters used in scripts around the world. Java stores all characters as their Unicode values.

29
Q

Escape sequence

A

Starts with the backslash character ( \ ) and is followed by one of more control characters that allow you to control the way that output is displayed. For example, the escape sequence that causes the output cursor to go to the next line is \n.

For example:
System.out.println(“These are the top sellers:\n”);
System.out.println(“Butter\nMilk\nSugar”);
Will print:
These are the top sellers:
Butter
Milk
Sugar

30
Q

Common escape sequences / characters

A
  • *\n** - Newline: Advances the cursor to the next line
  • *\t** - Horizontal tab: Moves cursor to the next tab stop
  • *\b** - Backspace: Moves cursor back or left one space
  • *\r** - Return: Moves cursor to the beginning of current line
  • *\** - Backslash: Prints a backslash
  • *'** Single quote: Prints a single quote
  • *"** Double quote: Prints a double quote
31
Q

Camel casing

A

A way of naming variables/methods such that each word after the first begins with a capital letter and there is no punctuation in between the different words. For example, studentStudyHall is camel cased and proper Java convention.

32
Q

What is the difference between an instance method and a static method?

A

Instance methods operate on objects whereas static methods do not. For example, in Java numbers are not objects so you can never invoke a method on a number. Instead, you pass a number as an argument (explicit parameter) to a method, enclosing the number in parentheses are the method name:
double root = Math.sqrt( 9 );

33
Q

Scope of a variable

A

Where a variable can be accessed or used, which is based on the area of code in which it is defined. For example, if you want to count the iterations of a loop and return the value after the loop has ended, then you need to declare the variable outside of the loop (before it begins) so you can use it both inside and outside that block of code. As a result, there can be more than one variable with the same name as long as they have different scopes.

34
Q

Concatenation

A

The operation of joining character strings. For example, the concatenation of “comp” and “ute” is “compute”.

35
Q

Parameters

A

Parameters are used to pass information to a method. There are two main types:

  1. Implicit - The object on which a method is invoked. For example, in the call f.x(y), the object x is the implicit parameter of the method f.
  2. Explicit - A parameter of a method other than the object on which it’s invoked. In the example above, y is the explicit parameter of the method f. However, note that a method does not have to have explicit parameters!
36
Q

Instance method

A

A method with an implicit parameter; that is, a method that is invoked on an instance of a class.

37
Q

Instance of a class

A

An object whose type is that class.