OOP Flashcards
https://docs.oracle.com/javase/tutorial/java/concepts/index.html
What are the two characteristics of an Object
State, Behaviour
What is State
Fields/Variables
What is Behaviour
Methods/Functions. Methods operate on an object’s internal state and serve as the primary mechanism for object-to-object communication
What is Data Encapsulation
Hiding internal state and requiring all interaction to be performed through an object’s methods is known as data encapsulation
Why use Objects?
- Modularity: The source code for an object can be written and maintained independently of the source code for other objects. Once created, an object can be easily passed around inside the system.
- Information-hiding: By interacting only with an object’s methods, the details of its internal implementation remain hidden from the outside world.
- Code re-use: If an object already exists (perhaps written by another software developer), you can use that object in your program. This allows specialists to implement/test/debug complex, task-specific objects, which you can then trust to run in your own code.
- Pluggability and debugging ease: If a particular object turns out to be problematic, you can simply remove it from your application and plug in a different object as its replacement. This is analogous to fixing mechanical problems in the real world. If a bolt breaks, you replace it, not the entire machine.
What is a class?
A class is the blueprint from which individual objects are created.
What is Inheritance
Object-oriented programming allows classes to inherit commonly used state and behaviour from other classes.
What is superclass and subclass?
In the Java programming language, each class is allowed to have one direct superclass, and each superclass has the potential for an unlimited number of subclasses:
What is the syntax of creating a subclass?
subclassEx EXTENDS superclassEx
What is an Interface
An interface is a group of related methods with empty bodies.
What is the syntax to use an Interface?
classEx IMPLEMENTS interfaceEx
What is a Package?
A package is a namespace that organises a set of related classes and interfaces.
What does API stand for?
“Application Programming Interface”