You are on page 1of 7

spring & DI, Kafka, Rest, HTTP, Security & certificates, Java collections, OOP

Java/OOP interview questions:

1. Какво представлява обектно ориентираното програмиране?


- Object-Oriented Programming(OOPs) is a type of programming that is based on
objects rather than just functions and procedures.
Individual objects are grouped into classes. OOPs implements real-world
entities like inheritance, polymorphism, hiding, etc into programming.
It also allows binding data and code together.
2. Основните принципи на ООП:
- Inheritance
- Encapsulation
- Polymorphism
- Data Abstractionå
3. Какво представлява един обект?
- An object is a real-world entity which is the basic unit of OOPs for example
chair, cat, dog, etc.
Different objects have different states or attributes, and behaviors.
4. Какво представлява един клас?
- A class is a prototype that consists of objects in different states and with
different behaviors.
It has a number of methods that are common the objects present within that
class.
5. Какво е наследяване и какви видове наследявания познаваш в Java?
- Inheritance is a feature of OOPs which allows classes inherit common
properties from other classes.
For example, if there is a class such as ‘vehicle’, other classes like ‘car’,
‘bike’, etc can inherit common properties from the vehicle class.
This property helps you get rid of redundant code thereby reducing the overall
size of the code.
6. Какво е superclass и subclass?
7. Какво е полиморфизъм и да дадеш пример?
- Polymorphism refers to the ability to exist in multiple forms. Multiple
definitions can be given to a single interface.
For example, if you have a class named Vehicle, it can have a method named
speed but you cannot define it because different vehicles have different speed.
This method will be defined in the subclasses with different definitions for
different vehicles.
8. Какво е метод overloading и overriding и каква е разликата?
- Method overriding is a feature of OOPs by which the child class or the
subclass can redefine methods present in the base class or parent class.
Here, the method that is overridden has the same name as well as the signature
meaning the arguments passed and the return type.
- Method overloading is a feature of OOPs which makes it possible to give the
same name to more than one methods within a class if the arguments passed differ
9. Може ли private метод да бъде override-нат?
- Не. А защо не?
9. Какео е енкапсулация?
- Encapsulation refers to binding the data and the code that works on that
together in a single unit.
For example, a class. Encapsulation also allows data-hiding as the data
specified in one class is hidden from other classes.
10. Какво е метод overloading и метод overriding?
- Method overloading is a feature of OOPs which makes it possible to give the
same name to more than one methods within a class if the arguments passed differ.
- Method overriding is a feature of OOPs by which the child class or the
subclass can redefine methods present in the base class or parent class.
Here, the method that is overridden has the same name as well as the signature
meaning the arguments passed and the return type.
10. Каква е разликата между public, private и protected access modifier-и?
11. Какво представлява абстракция?
- Data abstraction is a very important feature of OOPs that allows displaying
only the important information and hiding the implementation details.
For example, while riding a bike, you know that if you raise the accelerator,
the speed will increase, but you don’t know how it actually happens.
This is data abstraction as the implementation details are hidden from the
rider.
12. Какво е абстрактен клас?
- An abstract class is a class that consists of abstract methods. These methods
are basically declared but not defined.
If these methods are to be used in some subclass, they need to be exclusively
defined in the subclass.
13. Може ли да се инстанцира един абстрактен клас?
14. Какво е интерфейс?
- It is a concept of OOPs that allows you to declare methods without defining
them. Interfaces, unlike classes,
are not blueprints because they do not contain detailed instructions or actions
to be performed.
Any class that implements an interface defines the methods of the interface.
15. Може ли един интерфейс да наследява друг интерфейс?
- Да може повече интерфейса да наследява.
15. Какво е конструктор?
- A constructor is a special type of method that has the same name as the class
and is used to initialize objects of that class.
16. Каква е разликата между интерфейс и абстрактен клас?
- Абстрактен клас може да има и други методи, освен абстрактни. Интерфейс има
само абстрактни методи
- Може да съдържа final и non-final променливи. Интерфейс съдържа само final
променливи by default
- Accessibility на мембърите в абстрактен клас са private, public, protected. В
интерфейс са само public.
- Абстрактен клас може да имплементира интерфейс
17. Какво е final променлива?
- A variable whose value does not change. It always refers to the same object
by the property of non-transversity.
18. Какво е exception и съответно как се handle-ват exception-и?
- Exception handling in Object-Oriented Programming is a very important concept
that is used to manage errors.
An exception handler allows errors to be thrown and caught and implements a
centralized mechanism to resolve them.
- A try/ catch block is used to handle exceptions. The try block defines a set
of statements that may lead to an error.
The catch block basically catches the exception
20. Какво е wrapper class в Java?
- A wrapper class converts the primitive data type such as int, byte, char,
boolean etc. to the objects of their respective classes such as Integer, Byte,
Character, Boolean etc
21. Какви типове данни познаваш в Java?
byte – 8 bit
short – 16 bit
char – 16 bit Unicode
int – 32 bit (whole number)
float – 32 bit (real number)
long – 64 bit (Single precision)
double – 64 bit (double precision)
22. Можем ли да маркираме конструктор да е final?
- Не.
23. Какво е static block в Java?
-A static block gets executed at the time of class loading. They are used for
initializing static variables.
24. Какво представлява един exception и как се handle-ва?
25. Какви видове exception-и познаваш в java?
Checked - Checked exceptions are also known as compile-time exceptions as these
exceptions are checked by the compiler during the compilation process to confirm
whether the exception is handled by the programmer or not.
If not, then the system displays a compilation error. For example,
SQLException, IOException, InvocationTargetException, and ClassNotFoundException.
Uncecked - The unchecked exceptions are those exceptions that occur during the
execution of the program.
Hence they are also referred to as Runtime exceptions. These exceptions
are generally ignored during the compilation process.
They are not checked while compiling the program. For example,
programming bugs like logical errors, and using incorrect APIs.

----- Collections ------


24. Какво е List?
- Elements can be inserted or accessed by their position in the list, using a
zero-based index.
A list may contain duplicate elements.
25. Какво е Map?
- Map interface maps unique keys to values. A key is an object that we use to
retrieve a value later.
A map cannot contain duplicate keys: Each key can map to at most one value.
26. Какво е Set?
- A Set is a Collection that cannot contain duplicate elements.
27. От Collections framework-а кое ти е любимото да използваш и какво представлява
Collections framework-a?
28. Каква е разликата между array и collection?
- Arrays are always of fixed size, i.e., a user can not increase or decrease
the length of the array according to their requirement or at runtime, but In
Collection, size can be changed dynamically as per need.
- Arrays can only store homogeneous or similar type objects, but in Collection,
heterogeneous objects can be stored.
- Arrays cannot provide the ?ready-made? methods for user requirements as
sorting, searching, etc. but Collection includes readymade methods to use.
29. Какво е List в Java?
- The List interface in Java is an ordered collection of elements.
It maintains the insertion order and allows duplicate values to be stored
within.
This interface contains various methods which enables smooth manipulation of
elements based on the element index.
The main classes implementing the List interface of the Collection framework
are ArrayList, LinkedList, Stack, and Vector.
30. Какво представлява LinkedList и какви видове познаваш?
- LinkedList in Java is a data structure that contains a sequence of links.
Here each link contains a connection to the next link.
- Singly Linked List: In a singly LinkedList, each node in this list stores
the data of the node and a pointer or reference to the next node in the list.
- Doubly Linked List: In a doubly LinkedList, it has two references, one to
the next node and another to the previous node.
31. Какво представлява ArrayList?
ArrayList: ArrayList provides us with dynamic arrays in Java. Though, it may be
slower than standard arrays but can be helpful in programs where lots of
manipulation in the array is needed.
The size of an ArrayList is increased automatically if the collection grows or
shrinks if the objects are removed from the collection. Java ArrayList allows us to
randomly access the list.
ArrayList can not be used for primitive types, like int, char, etc. We will
need a wrapper class for such cases.
31. Какво представлява Set interface-а и какви имплементации познаваш?
Set Interface: A set is an unordered collection of objects in which duplicate
values cannot be stored.
This collection is used when we wish to avoid the duplication of the objects
and wish to store only the unique objects.
This set interface is implemented by various classes like HashSet, TreeSet,
LinkedHashSet, etc. Since all the subclasses implement the set, we can instantiate
a set object with any of these classes
- HashSet: The HashSet class is an inherent implementation of the hash
table data structure.
The objects that we insert into the HashSet do not guarantee to be inserted
in the same order.
The objects are inserted based on their hashcode. This class also allows
the insertion of NULL elements. Let’s understand HashSet with an example
- LinkedHashSet: A LinkedHashSet is very similar to a HashSet. The
difference is that this uses a doubly linked list to store the data and retains the
ordering of the elements.
32. Запознат ли си с ConcurrentMap interface-а и някоя негова имплементация? И
какво представлява?
33. ConcurrentHashMap?
Key points of ConcurrentHashMap:

The underlined data structure for ConcurrentHashMap is Hashtable.


ConcurrentHashMap class is thread-safe i.e. multiple threads can operate on a
single object without any complications.
At a time any number of threads are applicable for a read operation without
locking the ConcurrentHashMap object which is not there in HashMap.
In ConcurrentHashMap, the Object is divided into a number of segments according
to the concurrency level.
The default concurrency-level of ConcurrentHashMap is 16.
In ConcurrentHashMap, at a time any number of threads can perform retrieval
operation but for updated in the object,
the thread must lock the particular segment in which the thread wants to
operate. This type of locking mechanism is known as Segment locking or bucket
locking. Hence at a time, 16 update operations can be performed by threads.
Inserting null objects is not possible in ConcurrentHashMap as a key or value.
31. Какво представлява HashMap?
- HashMap<K, V> is a part of Java’s collection since Java 1.2. This class is
found in java.util package.
It provides the basic implementation of the Map interface of Java. It stores
the data in (Key, Value) pairs, and you can access them by an index
of another type (e.g. an Integer). One object is used as a key (index) to
another object (value). If you try to insert the duplicate key,
it will replace the element of the corresponding key.
HashMap is similar to the HashTable, but it is unsynchronized. It allows to
store the null keys as well,
but there should be only one null key object and there can be any number of
null values.
This class makes no guarantees as to the order of the map. To use this class
and its methods, you need to import java.util.HashMap package or its superclass.
32. Какво представлява equals() метода?
It checks the equality of two objects. It compares the Key, whether they are
equal or not. It is a method of the Object class.
It can be overridden. If you override the equals() method, then it is mandatory
to override the hashCode() method.
33. Какво представлява hashCode() метода()?
This is the method of the object class. It returns the memory reference of the
object in integer form.
The value received from the method is used as the bucket number.
The bucket number is the address of the element inside the map. Hash code of
null Key is 0.
32. Solid принципи
1. SRP - Класът трябва да има една-единствена отговорност (т.е. само промени в
софтуерните спецификации могат да предизвикат промяна в спецификациите на класа)
2. Open-Closed Principle - „Софтуерните единици трябва да са отворени за
разширение, но затворени за промяна.“
3. Liskov Substitution Principle - Всеки наследник (подтип) трябва лесно да
заменя всичките си базови типове.
4. Interface Segregation Principle - „Много на брой малки интерфейси е по-добре
от един голям общ интерфейс.
5. Dependency Inversion Principle - Всички класове трябва да зависят от
абстракции и нито един не трябва да зависи от конкретен клас.

// General knowledge
1. Какви видове HTTP request-и познаваш?
2. Каква е разликата между PUT и PATCH?
3. Какво представлява OPTIONS request-a?
4. Какво е REST API и за какво най-общо се използва?
- REST съкратено от Representational State Transfer – стил софтуерна
архитектура за реализация на уеб услуги.
Най-общо, това е концепция за заделяне на системен ресурс, който се променя въз
основа на взаимодействието между клиент и сървър.
В общи линии клиентът прави заявка, сървърът я обработва и връща отговор,
съответстващ на заявката.
Архитектурният стил на REST прилага 6 условия и когато дадено приложение
покрива тези условия, то може да се нарече RESTful.
RESTful web services are services that follow REST architecture.
REST stands for Representational State Transfer and uses HTTP protocol (web
protocol) for implementation.
These services are lightweight, provide maintainability, scalability, support
communication among multiple applications that are developed using different
programming languages.
They provide means of accessing resources present at server required for the
client via the web browser by means of request headers, request body, response
body, status codes, etc.
5. Чувал ли си за концепта statelessness и какво той представлява?
The REST architecture is designed in such a way that the client state is not
maintained on the server. This is known as statelessness.
The context is provided by the client to the server using which the server
processes the client’s request.
The session on the server is identified by the session identifier sent by the
client.
6. Кои са основните компоненти на един HTTP request?

// Database questions
5. Какво е база данни и какви бази данни познаваш?
- Hierarchical databases (DBMS)
- Relational databases (RDBMS)
- Network databases (IDMS)
- Object-oriented databases
6. Какво е primary key и с както се отличават?
- A primary key is a field or the combination of fields which uniquely specify
a row.
The Primary key is a special kind of unique key. Primary key values cannot be
NULL.
For example, the Social Security Number can be treated as the primary key for
any individual.
7. Какво е foreign (външен) ключ?
- A foreign key is specified as a key which is related to the primary key of
another table.
A relationship needs to be created between two tables by referencing foreign
key with the primary key of another table.
Foreign key acts like a cross-reference between tables as it refers to the
primary key of other table and the primary key-foreign key relationship is a very
crucial relationship as it maintains the ACID properties of database sometimes.
8. Каква е разликата между primary mey и unique key?
- Primary key and unique key both are the essential constraints of the SQL, but
there is a small difference between them
Primary key carries unique value but the field of the primary key cannot be
Null on the other hand unique key also carry unique value but
it can have a single Null value field.
9. Какви видове JOIN познаваш в SQL?
- LEFT, RIGHT, INNER, OUTER
- Inner join returns rows when there is at least one match of rows between the
tables. INNER JOIN keyword joins the matching records from two tables.
- The left join is used to retrieve rows which are common between the tables
and all rows of the Left-hand side table.
- Right Join is used to retrieve rows which are common between the tables and
all rows of a Right-hand side table.
10. Как би написал следното query - имаш таблица Employees и в нея има различни
колони, като една от тях е employeeName.
Как ще вземеш всичките служители от тази таблица, чието име започа с буквата 'A'?
11. За какво се използва ключовата дума DISTINCT в sql?
- The DISTINCT keyword is used to ensure that the fetched value is only a non-
duplicate value.
The DISTINCT keyword is used to SELECT DISTINCT, and it always fetches
different (distinct) from the column of the table.
12. Какво е group by?

// Spring & Hibernate


1. Какво представлява Spring framework-a?
- Spring is the most broadly used framework for the development of Java
Enterprise Edition applications.
The core features of Spring can be used in developing any Java application.
We can use its extensions for building various web applications on top of the
Jakarta EE platform,
or we may just use its dependency injection provisions in simple standalone
applications.
2. Какво е dependency injection?
- Dependency Injection, an aspect of Inversion of Control (IoC), is a general
concept stating that you do not create your objects manually but instead
describe how they should be created. An IoC container will instantiate required
classes if needed.
3. Какво представлява Spring Bean?
- The Spring Beans are Java Objects that are initialized by the Spring IoC
container. By default, a Spring Bean is initialized as a singleton.
The Spring IoC creates the objects, wire them together, configure them, and
manage their complete lifecycle from creation till destruction.
The Spring container uses dependency injection (DI) to manage the components
that make up an application.
4. Какво е hibernate?
- Hibernate is an open-source and lightweight ORM tool that is used to store,
manipulate, and retrieve data from the database.
5. Какво представлява ORM?
- ORM is an acronym for Object/Relational mapping. It is a programming strategy
to map object with the data stored in the database.
It simplifies data creation, data manipulation, and data access.
6. Какво представлява lazy loading в hibernate?
- Lazy loading in hibernate improves the performance. It loads the child
objects on demand.
Since Hibernate 3, lazy loading is enabled by default, and you don't need to do
lazy="true".
It means not to load the child objects when the parent is loaded.
7. Какви начини на инжектиране познаваш в Spring? Или видове DI?
Constructor-based dependency injection − Constructor-based DI is accomplished
when the container invokes a class constructor with a number of arguments, each
representing a dependency on other class.
Setter-based dependency injection − Setter-based DI is accomplished by the
container calling setter methods on your beans after invoking a no-argument
constructor or no-argument static factory method to instantiate your bean.
8. Какво представлява IoC контейнера?
The Spring IoC creates the objects, wire them together, configure them, and
manage their complete lifecycle from creation till destruction.
The Spring container uses dependency injection (DI) to manage the components
that make up an application.

Java/OOP
Score: 1-10, starts from 1.
- Interfaces, Abstract, Inheritance - 3 points
- Knows them and can used them - 5
- Collections Basic 7
- Collections Advanced 8
- Nested classes, weak ref - 8
- Knows more than all of this - 9, 10
- JVM, Garbage, etc. ... LEVEL Intern GOD
General Knowledge (SQL, Security, HTTP, REST etc)
Score: 1-10, starts from 1.
Problem Solving
Score: 1-10, starts from 1.
- Almost works 3
- Simple working task - 5
- Near optimal solution - 8
- Optimal solutions (alone!) - 9 / 10
- Debug the task!
Soft Skills
Score: 1-10, starts from 5 ang goes up/down accordingly.
X-Factor
Score: 1-10, starts from 5 ang goes up/down accordingly.

You might also like