quiz2b Flashcards

(48 cards)

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
is-a relationships
inheritance (relationship between an object and the class of its member)
26
toString()
returns a String representation of the object
27
clone()
creates and returns a copy of the object
28
equals()
determines if an object is equal to another object
29
hashCode()
returns a unique int for the object
30
parent, super, base class
the existing classc
31
child, sub class
the derived class
32
T/F: a child class can override the parent implementation
true
32
can a superclass have multiple subclassses
yes
33
T/F: subclasses cannot be superclasses of other subclasses
false (subclasses can be superclasses of other subclasses)
34
T/F: a subclass can inherit directly from multiple superclasses
false (subclasses can only inherit directly from one superclass)
35
all classes inherit from the Object class
yes
36
what happens when you define the toString method
overriding an inherited definition
37
data abstraction
separates the logical properties of a datatype from its implementation
38
the type of relationship that defines polymorphism
is-a relationship (object of a subclass also being an object of any of the superclasses)
39
can a class extend more than one parent class
no
40
are constructors inherited
no (abstract classes cannot be instantiated)
41
what the efficiency of an algorithm measures
the amount of resources in solving a problem with the input size of n
42
the preferred implementation
it completes in less time but other consideration constraints impact preference
43
why you focus on worst case running time
it's easier to analyze and crucial to applications like gaming, finance, and robotics
44
what doesn't affect growth rate
constant factors or lower order terms
45
T/F: the slower the asymptotic growth rate, the better the algorithm
true
46
what f(n) O(g(n)) means
f(n) is the growth rate and doesn't grow more than growth
47
basic operation of an algorithm
the part of the implementation that most significantly affects the counting steps