OOP Pillars Flashcards
__________ in Java is a mechanism in which one object acquires all the properties and behaviors of a parent object
Inheritance
The idea behind inheritance in Java is that you can create new classes that are built upon existing _______.
classes
When you inherit from an existing class, you can reuse methods and fields of the parent class. Moreover, you can add new methods and fields in your current class also.
True or False
True
___________ means “many forms”, and it occurs when we have many classes that are related to each other by inheritance.
Polymorphism
___________ lets us inherit attributes and methods from another class. ___________ uses those methods to perform different tasks.
Inheritance lets us inherit attributes and methods from another class. Polymorphism uses those methods to perform different tasks.
Inheritance represents the ___ relationship which is also known as a ___________ relationship.
Inheritance represents the IS-A relationship which is also known as a parent-child relationship.
What are the Advantages of Inheritance?
- For Method Overriding (so runtime polymorphism can be achieved).
- For Code Reusability.
____ is a group of objects which have common properties. It is a template or blueprint from which objects are created.
class
________ is a class which inherits the other class. It is also called a derived class, extended class, or child class.
subclass
__________ is the class from where a subclass inherits the features. It is also called a base class or a _____ ____.
Superclass is the class from where a subclass inherits the features. It is also called a base class or a parent class.
________ is a mechanism which facilitates you to reuse the fields and methods of the existing class when you create a new class. You can use the same fields and methods already defined in the previous class.
reusability
The _______ keyword indicates that you are making a new class that derives from an existing class. The meaning of “_______” is to increase the functionality.
class Subclass-name extends Superclass-name
{
//methods and fields added here
}
extends
What are the three types of inheritance in java?
single, multilevel and hierarchical

In java programming, ________ and ______ inheritince is supported through interface only.
In java programming, multiple and hybrid inheritance is supported through interface only.
Is multiple inheritance supported by Java?
No
The most common use of ___________ in OOP occurs when a parent class reference is used to refer to a child class object.
polymorphism
Any Java object that can pass more than one IS-A test is considered to be __________
polymorphic
If a class has multiple methods having same name but different in parameters, it is known as ______ _________
Method Overloading
If we have to perform only one operation, having same name of the methods _________ the ___________ of the program.
If we have to perform only one operation, having same name of the methods increases the readability of the program.
What are the two ways to overload the method in java?
- By changing number of arguments
- By changing the data type
class Adder{
static int add(int a, int b){return a+b;} // 2 arguments
static int add(int a, int b, int c){return a+b+c;} //3 arguments
}
Method overloading is not possible by changing the return type of the method.
True or False
True
If subclass (child class) has the same method as declared in the parent class, it is known as _____ ________ in Java
method overriding
______ overriding is used to provide the specific implementation of a method which is already provided by its superclass.
- Method overriding is used to provide the specific implementation of a method which is already provided by its superclass.
_______ overriding is used for runtime polymorphism
Method overriding is used for runtime polymorphism
What are the 3 rules required for method overriding to work?
- The method must have the same name as in the parent class
- The method must have the same parameter as in the parent class.
- There must be an IS-A relationship (inheritance).
Can a static method be overridden?
No, a static method cannot be overridden.
____________ in Java is a mechanism of wrapping the data (variables) and code acting on the data (methods) together as a single unit.
Encapsulation
In __________, the variables of a class will be hidden from other classes, and can be accessed only through the methods of their current class.
encapsulation
We can create a fully encapsulated class in Java by making all the data members of the class _______.
private
Once the data member of class have been made private we can use _____ and _____ methods to ___ and ___ data
Once the data member of class have been made private we can use getter and setter methods to get and set data
The ____ ____ class is the example of a fully encapsulated class.
Java Bean
What are the 4 access modifiers?
- private
- default
- protected
- public
What is the accessibility scope of each access modifier?
private
default
protected
public

__________ is a process of hiding the implementation details and showing only functionality to the user.
Abstraction
example: sending SMS where you type the text and send the message. You don’t know the internal processing about the message delivery.
Within Parent class
public abstract int calculateSalary();
Child Class
You define what calculateSalary() function does in the child class
________ lets you focus on what the object does instead of how it does it.
Abstraction
______________ is the process of extracting shared characteristics from two or more classes, and combining them into a generalized superclass. Shared characteristics can be attributes, associations, or methods.
Generalization
IE. taking two similar classes that have shared attributes, and then creating a superclass and moving the shared attributes into and then extend those attributes to the subclasses. So the two original classes are now subclasses of the superclass that now contains the once shared characterson
___________ means creating new subclasses from an existing class. If it turns out that certain attributes, associations, or methods only apply to some of the objects of the class, a subclass can be created.
Specialization
ie. When it comes to Specialization, if there is a property that is only applicable to a specific subclass, such as Degree of Hazardousness, that property is placed in the class Piece of Cargo where-in this class also has all the properties of the Freight class with the concept of Generalization.

’
Any Java object that can pass more than one ____ test is considered to be polymorphic.
IS-A