Chapter 1: Overview Flashcards

1
Q

What are the problems with procedural languages?

A
  1. When several functions need to access both global and local data which causes lots of programming errors
  2. Does not model real-world where functions carry out tasks and data stores information
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a constructor?

A

A method called whenever a new object is created

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

What types of methods are private vs public?

A

Data fields are typically private while methods are public

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

What is inheritance?

A

The creation of one class derived or extended from a base class

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

Why might you use inheritance?

A

Makes it easy to add features to an existing class, makes it easy to reuse classes for a slightly different purpose (a key advantage of OOP)

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

What is polymorphism?

A

Polymorphism is treating objects of different classes the same way and allows different objects to implement the same method in different ways. For example, study() for the class economist() and data_scientist() both deriving from the base_class student() have different results

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

What is the biggest difference between C++ and Java?

A

Java has no pointers

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

What is the difference between value and object references in Java?

A

A value reference stores actual data (e.g. int intVal will store the value of intVal). An object reference stores the address of the object stored elsewhere in memory. “You can think of a reference as a pointer with the syntax of an ordinary variable”

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

Assignment: C++ vs Java

A

In C++, assignment copies the object, in Java, assignment copies the reference. The implication of course is that making updates to the object of reference will change any variables which refer to it

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

Equality: C++ vs Java

A

In C++ equality means the data in 2 objects is identical. In Java, equality means two references are equal.

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