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?