AP CSA Unit 2 - Using Objects

0.0(0)
studied byStudied by 7 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/46

flashcard set

Earn XP

Description and Tags

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

47 Terms

1
New cards

Object

Entity with data and operations that can manipulate the data

2
New cards

Class

Entity that is either:

1.) Program with only static methods

2.) Custom data type for building objects

3
New cards

Method

A sequence of instructions the object follows to perform a task

4
New cards

Parameter

Information needed by the method to complete the task

5
New cards

Argument

Actual data passed to method

6
New cards

Return Value

The information a method provides

7
New cards

Void

Means NO information is returned

8
New cards

Variable

A storage location in computer’s memory

9
New cards

What are the 3 properties for a Variable?

1.) Type of data being stored

2.) Name (identifier)

3.) Contents (Actual data)

10
New cards

int

For storing integer data

int age = 17;

11
New cards

double

For storing precise number data

double gpa = 3.95;

12
New cards

String

A sequence of characters (text)

System.out.println("Plano West")

13
New cards
term image

Simple Numeric Variables

14
New cards

Assignment Operator (=)

Assigns value (contents) to a variable

variable = value;

15
New cards
term image

Variable Syntax

16
New cards

Declaration

Type name;

17
New cards

Initialization

name = value;

18
New cards

Combined (Declaration & Initialization)

Type name = value;

19
New cards

Identifier

Name of variable, class, or method

20
New cards

Rules for Identifiers

1.) May contain letters, digits (0-9), underscore ( _ ) and dollar sign ($) characters

2.) Cannot start with digit

3.) No spaces are permitted

4.) Cannot be a reserved word

5.) Letters are case-sensitive: west, West, and WEST are different!

21
New cards

Reserved Word

Words defined to have special meaning in Java (Ex: int, public, void)

22
New cards

Java Naming Conventions: Variables and Methods

Starts with first word in all lowercase, subsequent words capitalized: myDogSpot

23
New cards

Java Naming Conventions: Classes

Starts with uppercase letter, each word capitalized: PlanoWestWolf

24
New cards

Java Naming Conventions: Constants

All uppercase letters, separate words with : NUMBER_ONE

25
New cards

Comment

Information for humans (programmers) that the compiler ignores

26
New cards

Single-Line Comment

All information to the right of “//” is ignored

//Single-Line Comment

27
New cards

Multi-Line Comment

All information between “/*” and “*/” is ignored

/*	This is
      a multi-line comment
      and is all ignored!
 */

28
New cards

Javadoc

Information can be extracted using tool to create documentation

  • Starts with “/**” and ends with “*/

  • Uses special tags like @author, @param and @return

29
New cards

File Heading

A 6-item comment at the top of each source file

<p><span style="font-family: Arial, sans-serif">A 6-item comment at the top of each source file</span></p>
30
New cards

Method Comment Heading

Describes the parts of each method

<p><span style="font-family: Arial, sans-serif">Describes the parts of each method</span></p>
31
New cards

Object Variables

Variable that contains the memory address, or reference, of the object

Its type is the name of a class

32
New cards

Declaring the Object

Designate a name for referring to the object

ClassType name;

33
New cards

Instantiation

Building (constructing) an object by calling on a class’ constructor

name = new ClassType();

Some constructors accept parameters – allowing us to specify initial values

Rock mossy = new Rock(Color.GREEN);

Some constructors accept multiple parameters

Location loc;
loc = new Location(5, 7);

34
New cards

Calling Methods

After instantiating your object, you can call, or invoke, its methods

35
New cards

Public Interface

The methods defined by a class for public use

36
New cards

API (Application Programming Interface)

Defines the public interface for classes and methods in the Java library

37
New cards

Return Method

A method that returns a value when called

38
New cards

Void Method

A method that does not return information

39
New cards

Accessor Method

Does not change the object’s data

40
New cards

Mutator Method

Changes the object’s data

41
New cards
term image

Calling Methods With Objects

42
New cards
term image

Calling Return Methods With Objects

43
New cards

Package

A grouping of logically-related classes

44
New cards

Import Statement

Identifies a class defined in a different package

45
New cards

Overload

Method is defined multiple ways

46
New cards

Concatenation

Joining two strings together to form a new string

<p><span style="font-family: Arial, sans-serif">Joining two strings together to form a new string</span></p>
47
New cards

int length()

Returns the number of characters (visible + white space) in the string

String school;
school = new String("Plano West");
int count = school.length();
// Returns as 10