OOP Flashcards
What is the difference between a class and an object
A class is the blueprint to make objects. Objects are an instance of a class.
What are you four access modifiers
- Public
- Private
- Default
- Protected
Access Modifier: Public explain
Access level is everywhere
Access modifier: Private
Access only from within the class. Cannot be accessed outside of the class
Access modifier: Protected
Access from only within the package and outside the package through the child.
Access modifier: Default
Access level is only within the package. It cannot be accessed from outside the package
Abstract and Interface explained
Both are contracts.
Abstract class is a class that cannot be created and has at least one abstract method. Mixture of unique and generalized methods that your subclasses will inherit.
Interface: Just abstract methods, anything that implements the interface has to define the method. o You want to specify the behavior of a particular data type, but not concerned about who implements its behavior
What is a static method
A static method is a method that pertains to a class not an object. This allow the method to be called with an instance of an object. Can only call other static methods and static variables.
What is a singleton
ensure that only one instance of a class is created and provide global access point to the object
What are the main concepts of OOP
- Abstraction
- Encapsulation
- Polymorphism
- Inheritance
Explain Abstraction
each object should only expose a high-level mechanism for using it. The internal implementation details are hidden. It only reveals operations relevant for other objects
When would you use a static method
The code in the method is not dependent on instance creation and is not using any instance variable.
A particular piece of code is to be shared by all the instance methods.
The definition of the method should not be changed or overridden.
you are writing utility classes that should not be changed.
Explain Polymorphism
override/overloading meaning that you can have a method with the same name as the parent with different functionality
Explain Inheritance
Reuse common logic and extract the unique logic into a separate class. Child receives stuff from the parent
Overriding
replaces that the function inherted from the parent does
Overloading
defining multiple methods with the same name but with different parameters.
What is MVC
Model view controller
Model: is the data -> so the SQL
view: is the ui
controller: is what makes changes to the other two.
What is MVC
Model view controller
Model: is the data -> so the SQL
view: is the ui
controller: is what makes changes to the other two.
What does SOLID stand for?
S - Single Responsibility Principle (known as SRP) O - Open/Closed Principle L - Liskov’s Substitution Principle I - Interface Segregation Principle D - Dependency Inversion Principle
Explain S - Single Responsibility Principle (known as SRP)
class should be having one and only one responsibility
O - Open/Closed Principle
classes should be open for extension but closed for modification”. What is means is that if the class A is written by the developer AA, and if the developer BB wants some modification on that then developer BB should be easily do that by extending class A, but not by modifying class A.
L - Liskov’s Substitution Principle
parent classes should be easily substituted with their child classes without blowing up the application
Interface Segregation Principle
many client specific interfaces are better than one general interface
Dependency Inversion Principle
classes should depend on abstraction but not on concretion
High-level modules should not depend on low-level modules.
What does SOAP stand for?
Simple Object Access Protocol
What is SOAP
SOAP is an application communication protocol
SOAP is a format for sending and receiving messages
SOAP is platform independent
SOAP is based on XML
SOAP is a W3C recommendation
What is HTTP
Hypertext Transfer Protocol
What is REST
Representational state transfer
is a software architectural style that defines a set of constraints to be used for creating Web services.
REST constraints
Client–server Stateless Cacheable Uniform interface Layered system Code on demand
XML
Extensible Markup Language