0% found this document useful (0 votes)
17 views2 pages

Java SB: Core Concepts and Practices

The document outlines various topics related to Java programming, including memory management, exception handling, strings, core Java concepts, threading, streams, coding challenges, collections, testing, SQL, Spring Boot, Spring Security, microservices, and file handling. Each section includes specific subtopics and questions that delve into the details of each area. Additionally, it touches on project architecture and design patterns used in current projects.

Uploaded by

Vaibhav Mittal
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

Java SB: Core Concepts and Practices

The document outlines various topics related to Java programming, including memory management, exception handling, strings, core Java concepts, threading, streams, coding challenges, collections, testing, SQL, Spring Boot, Spring Security, microservices, and file handling. Each section includes specific subtopics and questions that delve into the details of each area. Additionally, it touches on project architecture and design patterns used in current projects.

Uploaded by

Vaibhav Mittal
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

​ Memory Management
1.1.​ Heap and stack memory space, and how they work.
1.2.​ Type of garbage collectors
2.​ Exception handling
2.1.​ Types of exceptions in java
2.2.​ Try with resource
3.​ Strings
3.1.​ Different between creating string using string literal and string buffer
3.2.​ Explain String class
4.​ Core Java
4.1.​ Difference between protected and default access modifiers
4.2.​ Abstraction
4.3.​ Method Hiding
4.4.​ SOLID principles
4.5.​ What is an Immutable class? Have you used this in any project?
4.6.​ What is singleton class
5.​ Threading
5.1.​ Executor framework in java
5.2.​ Volatile keyword
5.3.​ Race condition
6.​ Stream
6.1.​ For a given array, collect squared values of each and find out the average of
squared values which are greater than 100.
6.2.​ Intermediate and terminal operation in stream
6.3.​ Functional Interface(2)
6.4.​ Why do we have default methods?(2)
6.5.​ Given a sentence, concatenate the first letter of each word.
6.6.​ We have a stream like ‘aabbccdefff” return each unique char with its frequency in
a single string. A2b2c2d1e1f3
6.7.​ You have a list of object cars. Each car will be for one market. I want to fetch the
cars based on each market. Eg. for india market cars will be x,y,z
7.​ Coding
7.1.​ Given a string s containing ‘(‘ ‘{‘ ‘[‘, print true if the open bracket has close
brackets.
7.2.​ Write a method that takes 2 inputs as lists and returns a list with the sum of the
numbers of the list.
7.3.​ Write a function that extracts all integer numbers from a string and returns their
sum. Eg. abc123sjkj-54jkj11. See 54 is negative.
7.4.​ We have a string that removes non alphabet characters and empty spaces from
that string.
8.​ Collections
8.1.​ Collection framework hierarchy
8.2.​ Explain hash map internally
8.3.​ Contract between equals and hash code
8.4.​ Difference between hash set and linked hashset and treeset
9.​ Testing
9.1.​ Testing pyramid
9.2.​ Test containers
10.​ SQL
10.1.​ ACID properties
10.2.​ View in database
10.3.​ Indexing in sql
10.4.​ We have two tables, one customer and another order. One customer can have
many orders. The task is to get the list of customers who do not have any orders.
Do Not use subquery.
11.​ Spring Boot
11.1.​ What is dependency injection and different types of dependency injections in
spring boot.
11.2.​ Difference between path variable and query param
11.3.​ How to handle exception handling in spring boot.
12.​ Spring Security
12.1.​ Lets say there are 5 api, those 5 api can be accessed by role ADMIN, how will
you do it.
12.2.​ How will you check whether he is admin or not?
12.3.​ How you handle the authentication and authorization in your spring boot
application.
13.​ Microservices
13.1.​ What is Service Discovery
13.2.​ What is circuit breaker
14.​ File Handling
14.1.​ In a small microservice, I want to process a file and do some processing and
pass the data to the UI. How to do this in spring boot.
15.​ Project
15.1.​ How is the current architecture of your project?
15.2.​ What design patterns do you use in your current project?
16.​

Common questions

Powered by AI

ACID properties in databases stand for Atomicity, Consistency, Isolation, and Durability. These properties ensure that database transactions are processed reliably. Atomicity guarantees that each transaction is treated as a single unit, which either completely succeeds or fails. Consistency ensures that a transaction brings the database from one valid state to another, preserving database invariants. Isolation ensures that concurrently executing transactions do not affect each other's execution. Durability ensures that once a transaction is committed, its changes are permanent even in the case of a system failure. Together, they maintain data integrity and prevent anomalies.

Method hiding in Java occurs when a static method in a superclass is redefined in a subclass. In this scenario, the method in the subclass hides the one in the superclass, meaning calls to the method are handled by the class type of the invoked object. Method hiding is different from method overriding, where an instance method in the subclass replaces an instance method in the superclass. In overriding, the subclass method is invoked, regardless of the reference type, when called on an object of the subclass type, thereby adhering to runtime polymorphism.

Default methods in Java interfaces allow developers to add new functionality to interfaces without breaking existing implementations of the interface. This provides backward compatibility, as classes implementing the interface are not forced to implement new methods, enabling the evolution of APIs over time. Default methods also allow code reusability by defining behavior within interfaces, reducing the need for utility classes. They provide a way to ensure a standard behavior across multiple classes and can also help in achieving multiple inheritance of behavior.

A race condition occurs in multi-threaded programs when the output or behavior of the software depends on the relative timing of events such as thread execution. This situation arises when multiple threads access and manipulate shared data concurrently, leading to unpredictable results. Race conditions can be prevented by synchronizing access to shared resources, using techniques such as locks, semaphores, and synchronized methods or blocks in Java. By ensuring that only one thread can access the critical section at a time, synchronization prevents conflicting operations from executing simultaneously.

In Java, stack memory is used for static memory allocation and the execution of a thread, while heap memory is used for dynamic memory allocation of Java objects and JRE classes at runtime. Stack memory operates in a LIFO (last in, first out) manner, providing rapid access and deallocation of variables as methods are called and return. Heap memory is more loosely managed as it is used for objects that may have a variable lifespan and does not follow a strict order. It allows objects to be accessible globally throughout the application, but it requires garbage collection to free up unused objects.

Service discovery in microservices is a mechanism by which services find all the services they need to communicate with. It includes both registration and discovery processes. Services are registered in a service registry when they start and deregistered when they stop. A service registry maintains an up-to-date list of available service instances along with their network locations. Clients or other services can then query the registry to locate instances of a service. This approach decouples, abstracts, and automates the process of looking up network locations of service instances, enhancing system flexibility and scalability.

The StringBuffer class in Java is mutable, meaning it can be modified after creation, which makes it suitable for operations involving frequent modifications, like appending or inserting characters. It is synchronized and thread-safe. In contrast, a string literal creates an immutable String object, which cannot be changed once created. Any modification requires the creation of a new String object. StringBuffer is beneficial when working with dynamic strings that change frequently since it allows modifications to be made in-place without creating new objects, thus saving memory and improving performance.

The Executor framework in Java abstracts the creation, management, and coordination of threads, providing a more flexible and robust solution compared to handling individual thread instances. By using Executors, developers can easily manage a pool of threads, reuse threads, and control concurrency levels more effectively. This framework supports the scheduled execution of tasks, and simplifies error handling and thread lifecycle management. The ExecutorService interface in the framework addresses issues such as scalability and resource management, which can be cumbersome when using standalone thread instances.

Implementing the SOLID principles—Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion—improves object-oriented design by enhancing the maintainability, flexibility, and scalability of software. These principles encourage developers to design systems where classes have a single responsibility, systems are extendable without modification, objects can be substituted with their subtypes without affecting behavior, interfaces are client-specific, and dependencies are managed through abstractions. This results in code that is easier to understand, test, and refactor, leading to enhanced overall quality and reduced risk of major issues during modifications or extensions.

A circuit breaker in microservices architecture is a design pattern used to detect failures and prevent the application from repeatedly attempting to execute actions that are likely to fail. It temporarily blocks access to a failing service to give it time to recover, thus avoiding exacerbating the problem and minimizing outages across distributed systems. This helps in improving the system's overall resilience and stability by preventing cascading failures and allowing for graceful service degradation rather than a complete system crash.

You might also like