CS 180: Methods, Classes, and Arrays

0.0(0)
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/17

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

18 Terms

1
New cards

Java classes include…

  • Fields (attributes of an object or the class)

  • Methods (operations on an object or the class)

2
New cards

Static field values

Same for all methods

3
New cards

Non-static field value

each object has its own

4
New cards

What are instance variables

non-static fields in a class declaration

5
New cards

What are class variables

Static fields in a class declaration

6
New cards

Local variables

variables in the method or block

7
New cards

Class variables

static fields in a class declaration

8
New cards

Instance variables

Non-static field in a class declaration

9
New cards

Parameters

variables in a method declaration

10
New cards

What is a method

A parameterized block of code that may return a value

11
New cards

Static method

  • Can only access static fields and other static methods in the class

  • Can be called using class name. i.e. Math.pow(2,5)

12
New cards

Non-static method

  • May access non-static fields associated with the particular object

  • Must be associated with an object, e.g., t3.describ()

  • If no object is specified, “this” is implied

13
New cards

Methods are useful for…

  • Reusability

  • Readability

  • Modularity

14
New cards

Method Syntax

return_type methodName(param_list) {
     statements;
     return; // If needed
}

15
New cards

Basic variable scope

Usable from the point of declaration to the end of the enclosing block

16
New cards

“Special” Variable scopes

  • Parameters: accessible within the method body, can “hide” fields with the same name

  • For loop variable: accessible within heading and body

17
New cards

this refers to…

the current object

18
New cards

Signature

the name and parameter types of a method/constructor