OOP - Object Oriented Programming Flashcards
What are six core concepts of Object Oriented Programming
Objects, Classes, Inheritance, Polymorphism, Abstraction, Encapsulation
An entity that has a state & behavior, and can be physical or logical
Object
An object can be defined as an instance of a _____
Class
What can objects do without knowing the details of each other’s data or code?
Communicate
What is necessary for objects to communicate?
The type of message accepted and the type of response returned
Java classes define what two things relating to objects?
Data types and methods
A class can be defined as a ____ from which you can create an individual object.
Blueprint
Do classes consume space?
No
What are two advantages of Object Oriented Programming compared to Procedure Oriented Programming?
Easier development & maintenance (including when upscaling), Data hiding
A Java constructor is a block of code similar to what?
The method
What Java entity is called when an instance of an object is created and memory is allocated for the object?
A constructor
A Java constructor is a special type of method which is used to do what?
Initialize the object
When an object is created, the compiler makes sure that constructors for all of its ____ are called.
Subobjects (member & inherited objects)
What must members have for constructors to be called automatically when an object is created?
Default constructors / constructors without parameters
What can be done when an object is created but members do not have default constructors or constructors without parameters?
Parameterized constructors can be called using an initializer list
Why do constructors have this name?
Because they construct values at the time of object creation
Does the Java compiler create a default constructor if your class doesn’t have any?
Yes
One of three rules defined for the constructor is that the constructor name must be the same as ____.
Its class name
One of three rules defined for the constructor is that a constructor must have no explicit ____.
Return type
One of three rules defined for the constructor is that a Java constructor cannot be what three things?
Abstract, static/final, asynchronized
What are the two types of constructors?
Default and parameterized
The default constructor is a ____ constructor that the Java compiler inserts on your behalf.
No-argument
What is the (default) behavior of the default constructor?
It contains a “default” call to super();
If you implement any constructor, will you continue to receive a default constructor?
No
What is a parameterized constructor used for?
To provide different values to distinct objects
In Java, a constructor is just like a method but without what?
A return type
What is the technique in Java of having multiple constructors with different parameter lists?
Constructor overloading
How are constructors arranged in constructor overloading?
Such that they perform different tasks
How does the compiler differentiate constructors in constructor overloading?
By the number & types of parameters
Is a constructor or a method used to intialize the state of an object?
Constructor
Is a constructor or a method used to expose the behavior of an object?
Method
Must or must not a constructor have a return type?
Must not
Must or must not a method have a return type?
Must
Is a constructor invoked explicitly or implicitly?
Implicity
Is a method invoked explicitly or implicitly?
Explicitly
Does the Java compiler provide a constructor if one is not already present?
Yes
Does the compiler provide a method?
No