Basic OO concepts in Java/C++ Flashcards
For what languages are pointers implicit?
Java and Ruby
For what language are pointers handled explicitly?
C/C++
In Java what thing does the linkedList structure look like?

How do Ruby variables work?

How do you declare a pointer, allocate memory and set the variable in C/C++?
int * ptr;
ptr = malloc(sizeof(int));
*ptr = 5;
How do you use a pointer in C/C++ of an existing variable.
int x = 5;
int * intptr = &x;
How does the -> operator work in C++
int value = myList->data;
How would you access myLists’s print method?
It dereferences myList, then get the “data” field.
It would be shorthand for (*myList).data, the brackets are required to ensure the dereferncing is done first.
myList->print( ) is equal to (*myList).print( )
How do you return the memory memory when you are done with an object in C++?
How does it work?

In general how do pointer types work in most languages?

How do you cast a pointer to another type and why is it a bad idea?

How do you define a class in Java? (what is the code)

How do you define a class in C++ (the code in one file)

What is a null constructor and how are they used in a class?

What does it mean for a constructor to be overloaded? How does this affect the null constructor?

What is the unique way constructors are used in C++ that can increase the speed of initialization?
What is the specific code?

What are the advantages of using door(numdoor) vs door = numdoor (objects as fields)

How do you use a class in Java?

What does the public setting in a class do?
A public class makes it visible from the outside world - it can have a main( ) method that will be invoked. However you can only have one public class.
In java, how do you create a new object and how do you access the object fields or methods

How do you compile in general with g++?
How do you compile and name the a.out file at the same time?
g++ myfile.cpp
add -0 <filename></filename>
g++ myfile.cpp -o myprogram
What is a namespace and how is it used?

In C++ code a simle node class

In C++ what is the code for a simple list class?

What are the C++ nodes and list methods code?

In general, how does main work in C++?

Give an example of coding main in C++

What are extraction operators and how do they work?

When using classes in C++, when do we need to use unqualified vs qualified names?

What is an example of and code fr a heap-based object in C++?

What is an example of and code for a stack-based object in C++?

In C++ stack vs heap based objects, why use one over the other?

What is the diagram for class hierachy for our general linkedlist example?


Using Java and our linkedlist example, what is the code for the Node class?

In general, what is a concrete class and what is an abstract class (in Java)
Concrete - fully implemented, meant to be instantiated
Abstract - providing elements to be inherited by subclasses, not meant to be instaniated itself
- defined by adding the keyword abstract (abstract class ListItem{…)
- even though you can never create an instance of an abstract class, we can define constructors
- theses constructors are there to assist with inheritance

using print( ) as an example, we have an abstract class: ListItem. How do you enforce the need for subclasses of ListItem to have a print method

Can a method be defined as abstract in a concrete class? Why?

In our ListItem example, what is the code for subclass for intAtom? (in Java)

In our ListItem example, what is the subclass Java code for Intchar?

In our ListItem example, what is the subclass code for GenericList?

What is happening in the following code?


How does Dynamic Class binding work with the ListItem?

What is polymorphism and what are the benefits?

How do signatures work with abstract classes and subclasses?

Why do abstract classes exist?

Why can’t you use ( ) at the end of a stack based null constructor in C++?
putting ( ) will turn it into a forward reference(used in separate compilation)