OOP terms Flashcards

1
Q

what are the attributes of the object

A

its state eg colour, age,, size

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

what is the behaviour of the object

A

its functionality eg walk, sing

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

what is a class

A

a blueprint for a custom type

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

what does UML stand for

A

unified modeling language

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

what does + mean inUML

A

Public

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

what does - mean in UML

A

Private

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

create an object of class student

A

Student studentName = new Student();

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

what does encapsulate mean

A

not allow it to be exposed to the world

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

when are getters and setters used

A

when variables are private

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

why do we use getters and setters rather than leaving variables public

A

so that they cant be changed to crap eg length being a minus number

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

what is stack memory used for

A

variables and function calls

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

what is heap memory used for

A

to store objects

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

formal name for getters and setters

A

instance methods

accessors and mutators

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

creating an array of objects

A

type(class name) arrayName = new type[x]

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

what is method overloading

A

when there are more than one method with the same name but the compiler can tell them apart by their parameters/ list of parameters

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

why might static variables be used

A

universal to everyone

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

how are static variables accessed

A

ClassName.VariableName

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

can static variables be accessed outside of the class without creating an pbject of that class

A

yes

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

where are static variables stored

A

stack

20
Q

what is a java interface

A

the minimum methods that must be implemented for the object to be useful

21
Q

example of making a class that uses an interface

A

public class Rectangle implements Shape

22
Q

what is a constructor

A

a method which initialises an object

23
Q

when are constructors invoked

A

object creation

24
Q

if you don’t make a constructor what happens

A

java makes a deafult one for you, all attributes set to 0 or null

25
Q

does constructor have a return type

A

no

26
Q

what should constructor be called

A

same name as class

27
Q

what is a constructor which takes in parameters called

A

parametrized constructor

28
Q

what is constructor overloading

A

multiple constructors, each with different parameter lists needed to handle different cases

29
Q

what does key word this refer to

A

current object

30
Q

what is constructor chaining

A

reusing constructors from other classes

31
Q

when using constructor chaining, in what psoition should the call to the constructor be in the method

A

first statement

32
Q

what is inheritence

A

a new class is created using an existing classes methods, possibly adding more capabilities

33
Q

benefits of inheritence

A

more efficient
cheaper
loss copying

34
Q

in inheritance what is the parent class called

A

superclass

35
Q

in inheritence what is the child class called

A

subclass

36
Q

what is a direct subclass

A

inherits explicitly from superclass above

37
Q

what is an indirect subclass

A

inherits from classes above the class above

38
Q

in java, all classes have the superclass of what

A

Object

39
Q

can you inherit from multiple classes into one class

A

no

40
Q

are constructors inherited

A

no, must be called using super

41
Q

methods inherited from the superclass must be….

A

overrided

42
Q

how can superclass methods be accessed in a subclasss

A

using super.methodName( )

43
Q

what is polymorphism

A

when many objects can be passed into the same method and at runtime, the program is able to establish which versions to use

(late binding)

44
Q

what is upcasting

A

the typecasting of a child object to a parent object

45
Q

what is an abstract class

A

a superclass from which other classes inherit and so they all have a common design

but none of its methods are functioning, so it cannot be used to instantiate objects

similar to an interface

46
Q

what are concrete classes

A

classes which can be used to instantiate objects

47
Q

a class which contains abstract methods must be a

A

n abstract class