Java Flashcards
OO - What is a Class ?
A class is an abstract blueprint that creates more specific, concrete objects.
OO - What is an Object
An object is an instance of a class.
OO - Encapsulation
Encapsulation refers to the bundling of data with the methods that operate on that data within a single unit, i.e., class.
OO - Inheritance
Inheritance allows us to define a class in terms of another class, which makes it easier to create and maintain an application. This also provides an opportunity to reuse the code functionality and fast implementation time.
OO - Abstraction
Abstraction refers to the act of representing essential features without including background details - implementation
OO - Polymorphism - Compile Time
Compile-time polymorphism is also known as static polymorphism. This type of polymorphism is achieved by function overloading or operator overloading
OO - Polymorphism - RunTime
Runtime polymorphism, on the other hand, is also known as dynamic polymorphism. This type of polymorphism is achieved by method overriding
Collections - Interfaces
The Java Collections Framework provides a set of interfaces that define the behavior of different types of collections. These interfaces include List, Set, Queue, and Map.
Collections - Classes
The Java Collections Framework also provides a set of classes that implement these interfaces. These classes include ArrayList, LinkedList, HashSet, and TreeMap.
Collections - Generics
The Java Collections Framework uses generics to ensure type safety when working with collections.
Collections - Iterators
The Java Collections Framework provides an iterator interface that allows you to traverse the elements of a collection
Collections - Algorithms
The Java Collections Framework provides a set of algorithms that can be used to perform common operations on collections, such as sorting, searching, and shuffling.
Collections - Concurrency
The Java Collections Framework provides thread-safe implementations of some collection classes, such as ConcurrentHashMap and CopyOnWriteArrayList, which can be used in concurrent environments.
Generics - Type Safety
Generics provide compile-time type safety, which means that you can catch errors at compile time rather than at runtime.
Generics - Type Erasure
Java uses type erasure to implement generics. This means that the type information is removed at runtime, which allows you to use generics with legacy code that was written before generics were introduced.
Generics - Wild Cards
Wildcards allow you to specify a range of types that a generic class can work with. This is useful when you want to write code that can work with a variety of different types.
Generics - Bounded Type Parameters
Bounded type parameters allow you to specify a range of types that a generic class can work with. This is useful when you want to write code that can work with a variety of different types, but still maintain some level of type safety.
Generics - Generic Methods
Generic methods allow you to write methods that can work with different types of objects. This is useful when you want to write code that can work with a variety of different types, but don’t want to create a new class for each type.
Func.Prog - Lambda expressions
Lambda expressions are a new feature introduced in Java 8 that allow you to write functional-style code in Java. They are used to represent anonymous functions that can be passed around as values.
Func.Prog - Streams
Streams are a new feature introduced in Java 8 that allow you to process collections of data in a functional style. They provide a way to perform operations such as filtering, mapping, and reducing on collections of data.
Func.Prog - Immutability
Immutability is an important concept in functional programming. It means that once an object is created, it cannot be changed. In Java, you can create immutable objects using the final keyword or by using the java.util.Collections class.
Func.Prog - Higher Order Functions
Higher-order functions are functions that take other functions as arguments or return functions as values. They are an important concept in functional programming and can be used to create more expressive and reusable code.
Spring Boot - Dependency Inj - Inversion of Control
Dependency injection is based on the principle of inversion of control (IoC). This means that instead of your code controlling how everything works and what tools it needs, the control is inverted or shifted to the framework (Spring Boot) that manages and controls the flow of the program. In Spring Boot, this is achieved through the use of a container called the “application context”
Spring Boot - Dependency Inj - Types of Injections
There are three types of dependency injection (DI) in Spring Boot: constructor injection, setter injection, and field injection. Constructor injection is a recommended way of doing DI in Spring Boot because it ensures that the dependencies are available from the moment the object is created
Spring Boot - Auto Config - how it works
Spring Boot auto-configuration works by scanning the classpath for specific libraries and automatically configuring the application based on the presence of these libraries. For example, if you include the HSQLDB library in your project, Spring Boot will automatically configure an in-memory database for you
Spring Boot - Custom Auto Config
You can also create your own custom auto-configuration classes to configure your application. To do this, you need to create a class annotated with @Configuration and register it as an auto-configuration candidate by adding the name of the class under the key org.springframework.boot.autoconfigure.EnableAutoConfiguration in the standard file resources/META-INF/spring.factories. You can also use @Conditional annotations to specify when your custom auto-configuration should be used
Spring Boot - Starters
Spring Boot starters provide a quick and easy way to get started with Spring Boot. They include pre-configured dependencies that are commonly used together, such as web applications, security, data access, and more
Spring Boot Boot Strap process
- The first step in the bootstrap process is to create a new Spring Boot project. This can be done using the Spring Initializr, which is a web-based tool that generates a new project with all the necessary dependencies and configuration files.
- Once the project has been created, the next step is to configure the application. This involves setting up the application context, which is responsible for managing the lifecycle of the application.
- After the application has been configured, it can be started using the SpringApplication.run() method. This method starts the application context and initializes all the necessary components.
Spring Boot Starters examples
There are many different types of starters available for Spring Boot, including web starters, data starters, security starters, and more. Each starter provides a set of pre-configured dependencies that can be used to quickly get started with a specific feature or technology
Spring Eureka - Service Discovery
Spring Eureka provides a way for microservices to discover each other. Each microservice registers itself with the Eureka server, which maintains a list of all the available services. Other microservices can then query the Eureka server to find the location of the services they need to communicate with.
Spring Eureka - Load Balancing
Spring Eureka also provides load balancing capabilities. When a microservice needs to communicate with another service, it can query the Eureka server for a list of available instances of that service. The client-side load balancer can then choose one of the available instances to send the request to.
Spring Eureka - Fault Tolerance
Spring Eureka provides fault tolerance capabilities. If a service instance goes down, it will be automatically removed from the list of available services. When the instance comes back up, it will be automatically added back to the list.
Spring Config. Server - Centralised Config
Spring Cloud Config Server provides a central place to manage external properties for applications across all environments. As an application moves through the deployment pipeline from dev to test and into production, you can manage the configuration between those environments and be certain that applications have everything they need to run when they migrate
Spring Cloud Config - Git based
The default implementation of the server storage backend uses Git, so it easily supports labeled versions of configuration environments as well as being accessible to a wide range of tooling for managing the content. It is easy to add alternative implementations and plug them in with Spring configuration
Spring Cloud Config - HTTP API
Spring Cloud Config Server features an HTTP, resource-based API for external configuration (name-value pairs, or equivalent YAML content). It also allows you to encrypt and decrypt property values (symmetric or asymmetric) and is embeddable easily in a Spring Boot application using @EnableConfigServer
Spring Cloud Gateway - Routing
Spring Cloud Gateway is able to match routes on any request attribute. This allows you to write complex routing rules that take into account any aspect of the request
Spring Cloud Gateway - Load Balancing
Spring Cloud Gateway provides load balancing capabilities. It uses Ribbon to load balance requests to the specified service. Ribbon is a client-side load balancer that is often used in conjunction with the Netflix Eureka service registry
Spring Cloud Security -
Docker
What is a Docker Container?
What is a Docker Image?
Docker Hub
Dockerfile
Testcontainers
Testcontainers is an open source framework for providing throwaway, lightweight instances of databases, message brokers, web browsers, or just about anything that can run in a Docker container
12 Factor-app- The 12-factor app is a methodology for building software-as-a-service apps that are portable and scalable.
Codebase: The codebase should be tracked in revision control, with many deploys possible from the same codebase.
12 Factor-app-Dependencies
Dependencies should be explicitly declared and isolated.
12 Factor-app-
Configuration should be stored in the environment.
What is an Identifier in Java ?
A Identifier is the name of a Class, interface or Variable or Package or Label - case sensitive (can be any length but should be between 4-15)
- characters allowed - letters, digits, underscore and $
- cannot start with a digit
- cannot be a reserved word
Reserved words are
- keywords
- literals
keywords such as byte, char, short (data type reserved words)
keywords such as if, while, switch (flow control keywords)
modifiers such public, private (modifier keywords)
what does public access modifier mean
what does private access modifier mean
what does protected access modifier mean
what does static access modifier mean
what does final access modifier mean
what does abstract access modifier mean
what does module mean ?