Object Oriented Programming Term 2 Final

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

1/43

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

44 Terms

1
New cards

inheritance

allows new classes to be created based on existing classes, thus inheriting their properties and behaviour

2
New cards

superclass

class that can be extended to create a subclass; should not access the extra attributes and behaviours of a subclasssubclass

3
New cards

subclass

a class that extends a superclass and inherits its attributes and behaviours

4
New cards

pros of inheritance

code reusability, code maintenance, modularity (promotes breaking down code into smaller, specialized components)

5
New cards

cons of inheritance

tight coupling (difficult to modify base class without affecting derived class), fragile base class

6
New cards

conditional statement

a statement that only executes when a condition is true

7
New cards

while loop

executes a block of code repeatedly as long as a condition is true

8
New cards

iteration statement

statement that repeatedly executes a block of code

9
New cards

code for conditional statements

if (condition) {

code();

}

else {

code();

}

10
New cards

pros of OOP

  • modularity → makes code easier to modify and maintain

  • encapsulation → code doesn’t get modified accidentally

  • inheritance → reduces development time and increases quality of code

11
New cards

cons of OOP

  • not suitable for smaller projects

  • makes programs larger and slower

  • takes more time and effort

12
New cards

stack memory

holds variables and references to objects

13
New cards

heap memory

only holds objects

14
New cards

primitive data type

  • double: decimal value

  • int: whole numbers

  • boolean: true or false

15
New cards

reference data type

  • string

  • objects

16
New cards

declaration of a variable

giving a name and data type to a variable

17
New cards

initialization of a variable

giving a starting value to a variable using the assignment operator (=)

18
New cards

literal

a source code representation of a value f.e. binary representation

19
New cards

access modifier

used to set the visibility of classes, variables, constructors, and methods

20
New cards

instance variables

variables defined in a class where each variable represents an attribute of an object

21
New cards

precondition

a condition that must always be true before the execution of a code segment

22
New cards

postcondition

a condition that must always be true after the execution of a code segment

23
New cards

java.io package

contains classes for input and output

24
New cards

file class

used to read text files

25
New cards

hasNext()

returns true if there is another input

26
New cards

hasNextLine()

returns true if there is another line of input

27
New cards

hasNextInt()

returns true if there is another integer

28
New cards

for loop

a loop that repeats a code segment a given number of times

29
New cards

for loop code

for (int number = 0; number < 5; number++)

30
New cards

enhanced for loop

a for loop for traversing an array

31
New cards

enhanced for loop traversing code code

for (int number = 0; number < nums.length; number++)

32
New cards

enhanced for loop initialization code

int[] nums = {1, 2, 3, 4};

for ( int num : nums){

…}

33
New cards

1d array

a linear structure that holds one or more values of the same data type

34
New cards

element

an item stored in an array

35
New cards

off by one error

occurs when one tries to access an index value that is greater than the length of the array

36
New cards

polymorphism

the ability of an object to perform an action in different ways

37
New cards

initializing an array

DataType[] name = new DataType[length];

                                   int[] scores = new int[5];
38
New cards
39
New cards
40
New cards
41
New cards
42
New cards
43
New cards
44
New cards