quiz2b Flashcards

1
Q

T/F: objects are the instances of their classes

A

true

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

what declarations does a class contain

A

data declarations and method declarations

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

data declarations example

A

int size, char category

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

instance variable

A

a field that’s defined in a class and is allocated when an object is instantiated

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

class data

A

static data that all objects share

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

members

A

fields and methods that belong to the same class

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

access modifier

A

defines the circumstances under which a method or class can be accessed

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

the most liberal type of access

A

public access

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

public access

A

the usual declaration of classes; methods called by the client of the class

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

private access

A

the usual declaration of instance variables; methods called by other methods of the class

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

T/F: constructors hav a return value

A

false (constructors have no return value, it will cause compiler errors)

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

T/F: a class can have several constructors

A

true

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

the job of the class constructor

A

initialize the instance variables of the new object

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

T/F: a static method can access instance variables

A

false (static methods are associated with the class, so they don’t have access to the implicit parameter “this”)

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

T/F: a private method can be accessed by client code

A

false (nothing outside the class can access private methods)

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

T/F: a private attribute can be accessed within the equals method

A

true (it depends because if the equals method is inside, then it can access it, but if it’s outside, the it can’t access it)

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

T/F: instance attributes should be declared public

A

false (all instance attributes should be private)

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

T/F: all instance methods should ALWAYS be declared public

A

false (you can have private helper methods)

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

T/F: the return for accessors is usually void

A

false (an accessor is a getter, so if you have to give it back you can’t return void)

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

T/F: accessors have no parameters

A

true (don’t need to return data value)

21
Q

T/F: mutators have no parameters

A

false (mutators are setters, so you need to set a value and have its data)

22
Q

T/F: the return type for mutators is usually void

A

true (mutators don’t return anything)

23
Q

T/F: the signature of a method is the return type and parameter list

A

false (doesn’t include the return type, method name, and parameter list)

24
Q

has-a relationship

A

composition (demonstrated by a class that contains another class)

25
Q

is-a relationships

A

inheritance (relationship between an object and the class of its member)

26
Q

toString()

A

returns a String representation of the object

27
Q

clone()

A

creates and returns a copy of the object

28
Q

equals()

A

determines if an object is equal to another object

29
Q

hashCode()

A

returns a unique int for the object

30
Q

parent, super, base class

A

the existing classc

31
Q

child, sub class

A

the derived class

32
Q

T/F: a child class can override the parent implementation

A

true

32
Q

can a superclass have multiple subclassses

A

yes

33
Q

T/F: subclasses cannot be superclasses of other subclasses

A

false (subclasses can be superclasses of other subclasses)

34
Q

T/F: a subclass can inherit directly from multiple superclasses

A

false (subclasses can only inherit directly from one superclass)

35
Q

all classes inherit from the Object class

A

yes

36
Q

what happens when you define the toString method

A

overriding an inherited definition

37
Q

data abstraction

A

separates the logical properties of a datatype from its implementation

38
Q

the type of relationship that defines polymorphism

A

is-a relationship (object of a subclass also being an object of any of the superclasses)

39
Q

can a class extend more than one parent class

A

no

40
Q

are constructors inherited

A

no (abstract classes cannot be instantiated)

41
Q

what the efficiency of an algorithm measures

A

the amount of resources in solving a problem with the input size of n

42
Q

the preferred implementation

A

it completes in less time but other consideration constraints impact preference

43
Q

why you focus on worst case running time

A

it’s easier to analyze and crucial to applications like gaming, finance, and robotics

44
Q

what doesn’t affect growth rate

A

constant factors or lower order terms

45
Q

T/F: the slower the asymptotic growth rate, the better the algorithm

A

true

46
Q

what f(n) O(g(n)) means

A

f(n) is the growth rate and doesn’t grow more than growth

47
Q

basic operation of an algorithm

A

the part of the implementation that most significantly affects the counting steps