SL CompSci Unit 2

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

1/77

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.

78 Terms

1
New cards

accessor

a method that accesses an object but does not change it, normally returns a value.

2
New cards

access specifier

Indicates who has access to the information/code. Used on method headings and class level variables. If public anyone has access. if private, only usable within the class. Typically, methods are public and instance fields(class level(declared outside of methods) non-static variables) are private.

3
New cards

actual parameter

This is the explicit parameter in the calling statement only. The value must already exist in order for you to pass the value to the method. i.e. it actually exists.

4
New cards

API

documentation for all classes in the JDK. It has the public interface for the methods (basically the method heading and class description) so that someone can execute those methods. It does NOT include the information from the method body on how the task is completed. It includes public class level variables also.

5
New cards

argument

another name for the explicit parameter/actual parameter in a calling statement.

6
New cards

assignment operator

= is the operator used to place a new value into a variable.

7
New cards

class

a programmer-defined data type, typically a blueprint for an object. Contains the class level non-static variables that make up the attributes of the object and the methods/behaviors that the object can do.

8
New cards

constructor

a method that initializes a newly instantiated object, no return type, same name as the class.

9
New cards

double

the double type denotes floating-point numbers that can have fractional parts.

10
New cards

explicit parameter

input to a method - placed in the parenthesis following a method identifier. It can be in a calling statement or an method definition.

11
New cards

floating-point number

a number that can have a fractional part.

12
New cards

formal parameter

the explicit parameter in the method definition only. It must have a data type as you are declaring a variable/getting space to hold the values that are being passed to the method. They are not initialized here as they will get their value with someone invokes this method (i.e. they are initialized to the corresponding actual parameters value).

13
New cards

identifier

the name of a variable, method or class.

14
New cards

implicit parameter

The object on which a method is invoked. For example, in the call x.f(y), the object x is the implicit parameter of the method f. It is only in the calling statement. Can only have one per method that is invoked.

15
New cards

import

Java classes are grouped into packages. Use the import statement to use classes that are defined in other packages.

16
New cards

instantiation

In general it is the process of creating/initializing one instance of an object and requires the use of the new operator with a constructor method.

17
New cards

18
New cards

integer

a number that cannot have a fractional part

19
New cards

method

a sequence of statements that has a name, may have formal/explicit parameters, and may return a value. A method can be invoked any number of times, with different values for its parameters.

20
New cards

mutator

a method that changes the state of an object, usually a void method (returns nothing)

21
New cards

immutable

a class that has NO mutator methods. The String class is immutable.

22
New cards

object

a value of a class type

23
New cards

object reference

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

24
New cards

overloading

giving more than one meaning to a method name. An overloaded method is a method (same name) with multiple implementations in the same class with different parameter lists. ie it has a unique signature. No class can have two methods with the same signature.

25
New cards

package

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

26
New cards

parameter

an item of information that is specified to a method when the method is called. For example, in the call System.out.println("Hello, World!"), the parameters are the implicit parameter out and the explicit parameter "Hello, World!".

27
New cards

primitive type

in Java, a number type, char or boolean. Primitive types are not objects, and cannot invoke methods. They hold the value (instead of an address of the value). Ex. Double and Int

28
New cards

private implementation/private access specifier

the private implementation in a class describes the data inside its objects and the instructions for its methods. Not directly accessible outside of the class.

29
New cards

public interface

the public interface of a class specified what you can do with its objects. Basically, this is the information available in the public method definition/header. The statements inside the method are private.

30
New cards

return value

the value returned by a method through a return statement

31
New cards

return type

this is part of a method heading and shown in the public interface in an API for the class. It indicates the TYPE of data that is to be returned from the method.

32
New cards

type

A named set of values and the operations that can be carried out with them (if any).

33
New cards

variable

a symbol in a program that identifies a storage location that can hold different values.

34
New cards

Data Type

The data type tells the computer how much storage is needed for that variable and what things that data is allowed to do.

35
New cards

Creating a Variable

You must declare it using the following syntax before using it. You will ONLY declare it once.- dataType VariableName; ex: int age;

36
New cards

37
New cards

int

will hold whole numbers and can do whole number math functions - add, subtract, multiply, divide, modulus (remainder) uses 4 bytes of memory.

38
New cards

Objects

are entities in your program that you manipulate by calling methods of that class.

39
New cards

Reference Data Types

Objects belong to a class. The amount of storage for the object varies so the Variable name points to an address, not the actual data.

40
New cards

String

this is a special type of object. String variables will point to an address of where the data is located.

41
New cards

Initialize

You must initialize / assign a value to any variable before you can use it.

42
New cards

Syntax Rules for Identifiers

1) can only use characters, numbers, underscore "_" and dollar sign"$" 2) cannot start with a number 3) cannot use blanks 4) cannot use any other special symbols such as "," "/" or "&" 5) cannot use reserved keywords OR identifiers already declared in the program.

43
New cards

Case Sensitivity

Identifiers are case sensitive - NAME, Name, and name are three different identifiers.

44
New cards

Convention for Class Identifiers

Class identifiers start with upper case letters.

45
New cards

Convention for Variable and Method Identifiers

Variable and Method identifiers start with lower case names.

46
New cards

Meaningful Identifiers

Identifiers should be meaningful - use "gpa" not "g."

47
New cards

Concatenation

putting two separate fields together, side by side. Does not add the contents of the fields.

48
New cards

reserved

part of Java language. Ex: public, void, static

49
New cards

pre-defined in libraries

ex - method names like println

50
New cards

user defined

created by the programmer

51
New cards

Assignment

"=" assigns the value on the right to the variable on the left.

52
New cards

primitive variable

passes the actual value to be stored.

53
New cards

reference variable

stores the address of the object.

54
New cards

new operator

used from another class to create an object of this class.

an operator that allocates new objects - gets space and address of that space. (The amount of space needed is determined by the non-static class level variables known as instance fields in the object class)

55
New cards

class method

a sequence of instructions that accesses the data of an object.

56
New cards

PrintStream

a class with out as a pre-defined object created in the System class.

57
New cards

String class

a class for an object that contains a set of characters.

58
New cards

length method

returns the number of characters including special symbols and blanks that are contained in the string object passed as the implicit parameter.

59
New cards

toUpperCase method

returns a copy of the implicit parameter converted to have only upper case characters.

60
New cards

toLowerCase method

returns a copy of the implicit parameter converted to have only lower case characters.

61
New cards

replace method

carries out a search-and-replace operation, constructing a new string by replacing all occurrences of the first explicit parameter with the second explicit parameter.

62
New cards

Constructor method

instantiates the object - declare and initialize and return the reference (address) of the new object.

63
New cards

instantiating

the process of constructing the object using the new operator.

64
New cards

method name overloading

occurs if a class has more than one method with the same name (but different parameter types).

65
New cards

method signature

the name of the method along with the data types of the explicit parameter if there are any.

66
New cards

Return values

Information that some methods return after performing calculations or actions.

67
New cards

Void

The reserved word used in the method header/definition to indicate that a method does not return any value.

68
New cards

Test Programs

Programs that verify that one or more methods have been implemented correctly.

69
New cards

Packages / Libraries / Import

Collections of similar programs in Java that need to be imported into your program.

70
New cards

API (Application Programming Interface)

Documentation that lists the classes and methods of the Java library.

71
New cards

Variables

Used to store values that you want to use at a later time.

72
New cards

Identifiers

Names for variables, methods, and classes composed of letters, digits, and underscores, cannot start with a number or be a reserved word.

73
New cards

Initialization

All variables must be initialized before you access them.

74
New cards

Overloaded method

A method name is overloaded if a class has more than one method with the same name but different parameter types.

75
New cards

Double type

Denotes floating-point numbers that can have fractional parts.

76
New cards

Arithmetic operators

Operators such as +, -, and * used to combine numbers.

77
New cards

Multiple object variables

Can contain references to the same object.

78
New cards

Number variables

Store numbers, while object variables store references.