from term test Flashcards

1
Q

what is the dynamic type of c?

Car c = new Honda();

A

Honda type

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

in Java, a variable of type Z can hold a reference to:

A

an instance of type Z or an instance of any subclass Z

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

T/F

In Java and C++, it is possible to declare objects as either stack-based or heap-based

A

false

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

T/F

In C++, variables on the stack are deallocated automatically

A

true

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

Writing a method in a subclass that has the same signature as a method in the parent class, when polymorphism is not used is called:

A

shadowing

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

What is the purpose of OCCF?

A

To define a standard way of handling object construction, copying, assignment, and destruction to avoid resource leaks and undefined behaviour

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

T/F

You should override the copy constructor whenever possible to ensure a deep copy is made by default

A

false

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

In C++ when is the copy constructor automatically called?

A
  1. when making an object from another
    - Person p = q
  2. when passing the object as a value parameter
  3. when returning an object (not a pointer)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly