Object Oriented Programming Flashcards
What is a constructor?
A constructor is a special method that is called automatically when an object is created with the “new” operator.
It’s purpose is to initialize the attributes of an object when the object is created.
What does a constructor look like in java?
A constructor has the same name as the class name.
What is the scope of variables?
Scope refers to the parts of the code in which those variables can be used.
What’s the rule of thumb for variables?
Instance variables are accessible form within the class. And generally speaking: a variable is only accessible in its block.
What is ‘final’ used for?
Used to declare a constant (all caps).
What is overloading?
When we call a method over an existing method in a superclass.
What is an array?
An array has a particular number of cells when it is created (its capacity).
What happens when an array is full and we store to store past the last element in the array?
An exception is thrown.
What’s the difference between a formal parameter and an actual parameter.
Formal parameter comes from the variable in the list in the method definition.
Actual parameter is from invoking a method with an actual parameter.
What is modularity?
It refers to subdividing a large problem into smaller components, or modules, to make the design of a solution easier.
What is information hiding?
Information hiding refers to making implementation details inaccessible.