Java interview

  • OOP
  • Inheritance
  • Encapsulation
  • Polymorphism
  • Abstraction
  • Constructor
  • Object
  • Interface и class
  • Access modifiers such as private, default, protected and public
  • Abstract class and method
  • Exception and Error


OOPs in Java organizes a program around the various objects and well-defined interfaces. The OOPs Concepts in Java are abstraction, encapsulation, inheritance, and polymorphism


- it is possible to inherit attributes and methods from one class to another
- is a mechanism in which one object acquires all the properties and behaviors of a parent object
- Java does not support Multiple inheritance


- By encapsulating a class's variables, other classes cannot access them, and only the methods of the class can access them
- hiding the implementation of the class and separating its internal representation from the external class or interface


- is the ability to apply the same methods with the same or different sets of parameters in the same class or in a group of classes connected by an inheritance relation


- is the process of hiding implementation details from the user, giving the user only the functionality
- the user will own the information about what the object does, not how it does it


- All classes have constructors, whether you define them or not, because Java automatically provides a default constructor
- The constructor is a method that creates a kind of "framework" for the class. Every new object of the class must conform to it


- is an individual member of a class that has a particular state and behavior that is completely determined by the class
- Variables are used to store the state of the object
- The object is an instance of the class
- Any object can have two main characteristics: state - some data that the object stores, and behavior - actions that the object can perform


- A class is a template structure that allows you to describe an object, its properties (class attributes or fields) and behavior (class methods) in a program
- Class can consist methods, objects and constructors. Class is a template of an object, he has a body with fields and methods 


- An interface is a reference type, it is similar to a class. It is a collection of abstract methods. 
- A class implements an interface, thus inherits the abstract methods of the interface
- There is no implementation inside the interface
The interface only describes the behavior of some object
- Only immutable final fields can be in the interface

Abstract class and method

- Abstract class describes some general state and behavior that future classes - descendants of the abstract class - will have.
- Similar to interfaces, abstract classes can have abstract methods, an abstract method is a method without a body (without implementation), but unlike interfaces, abstract methods in abstract classes must be explicitly declared as abstract.

Access modifiers

- public, protected, default, and private.
- Protected - declarations are visible within the package or all subclasses
- Default - declarations are visible only within the package (package private)


- Keyword this is a link to the current class instance, we can use this word to call constructors, variables and object method’s 


- Static methods and variables are related to the class
- Static methods belong to a class, not an object. You can call them without creating an instance of the class
- From a static method you can access only static variables or methods

SQL basic commands

DML – Data Manipulation Language

Create table:


Add a row:

INSERT INTO nameoftable (1,2,3) VALUES (new1,new2,new3);

View the row you just created:

SELECT * FROM nameoftable;

Edit information in the table (for only existing records):

UPDATE nameofthetable
SET parameter = 22
WHERE id = 1;

Add new column in the table:

ALTER TABLE nameoftable ADD COLUMN nameofcolumn TEXT;

Delete rows with no value:

DELETE FROM name of t WHERE nameofcolumn IS NULL;
DELETE FROM nameoftable;

Return uniq values:

SELECT DISTINCT name of column FROM name of t;

Filter the result in rows only if condition is true:

SELECT * FROM nameoftable WHERE name of column > 8;


= equals
!= not equals
> greater than
< less than
>= greater than or equal to
<= less than or equal to

Filter the result to compare similar values:

SELECT * FROM name of t WHERE name of column LIKE ‘set here your text parameter’;
i.g. ‘Se_en’ or ‘A%’ (begins with “a”) or ‘%a’ (ends with “a”) or %man% (contains this word)

SELECT * FROM name of t WHERE name of column BETWEEN ‘A’ AND ‘J’; (not incl ‘J”)
or BETWEEN 1990 AND 2000; (incl all years)

Combine operator AND:

SELECT * FROM movies
WHERE year BETWEEN 1990 and 2000
AND genre = ‘comedy’;)

OR operator:

SELECT * FROM movies
WHERE genre = ‘comedy’
OR year < 1980;

Sort the result:

SELECT * FROM name of t
ORDER BY name of column DESC;
DESC — from high to low, ASC — low to high

Limiting the results:

SELECT * FROM name of t
ORDER BY name of column ASC


Calculate the number of rows:

SELECT COUNT(*) FROM nameoftable;

To combine the rows

CONCAT ( || ‘somethting’ ||):

SELECT *, CONCAT(age, name, salary) as concat FROM name of table;
SELECT ‘abc ‘ || ‘def’ || ‘ gh ‘ FROM DUAL;

Round to a whole number:

SELECT ROUND(column name, decimals кол-во знаков после запятой) from nameoftable;

SELECT ROUND(345.156, 2);

If null return your value:

SELECT name, NVL(id, 0) FROM nameoftable;

SUM of all the values in that column:

SELECT SUM(nameofcolumn) from nameoftabl;

Find the largest value in a column:

SELECT MAX(nameofcolumn) FROM nameoftabl;

Find the minimum value in a column:

SELECT MIN(nameofcolumn) FROM nameoftabl;

Find average value:

SELECT AVG(namecolumn) FROM nameoftable;


is using with COUNT, MIN, MAX, AVG, SUM

AS — rename a column 

Multiple tables join

SELECT * FROM nameoftable1 JOIN nameoftable2 ON =;

  • left JOIN — every row in the lefttable is returned in the result set
  • right JOIN — every in the right
  • inner join=join

Limited rows /strings:

SELECT * FROM nameoftable LIMIT 10;


merge the columns

SELECT column_name(s) FROM table1
SELECT column_name(s) FROM table2;
The UNION ALL clause allows us to utilize information from multiple tables in our queries, including duplicate values.
INTERSECT is used to combine two SELECT statements, but returns rows only from the first SELECT statement that are identical to a row in the second SELECT statement.
EXCEPT returns distinct rows from the first SELECT statement that aren’t output by the second SELECT statement

Как зайти в почту mail для бизнеса

Открыть стартовую страницу почты:

Нажать на кнопку «Вход»


Открывается окно входа, где необходимо выбрать опцию «Другой»:


И ввести полностью электронную почту в поле:


Далее нажать кнопку «Ввести пароль», заполнить корректно поле пароль и нажать кнопку «Войти»


Командная строка unix

Вывести содержимое папки включая скрытые
ls -al /home/

uname -r > logfile.txt
Вывод будет сохранен в logfile.txt в текущей директории. На экран ничего выведено не будет.

uname -r | tee logfile.txt
Вывод будет сохранен в logfile.txt в текущей директории. А также результат будет выведен на экран.

rsync -avzh откуда куда (пример user@new_server_name:/data/test /data/test)
если в пути откуда в конце нет слеша, то копируем папку, если есть / — то копируем то, что внутри папки

pwd — текущая директория

cd — домашняя директория

cd /user — перейти в директорию user

ctrl +R — поиск по введенным ранее командам

ctrl+C — завершить  текущую команду

ln -s file lnk — создать символическую ссылку (симлинк)

du -sk * | sort -rn — директории с сортировкой с размерами

du -sh dir/ — размер директории

unzip — разжать и распаковать zip-архив в текущую папку

head -2 file вывести первые две строки файла file, по умолчанию — десять строк
tail -2 file вывести последние две строки файла file , по умолчанию выводится десять строк

rm file – удалить file

rm -r dir – удалить каталог dir

Java: массив

String [] array = new String[10]; //создаем массив на 10 строковых элементов
int [] numbers = new int [10]; //создаем массив на 10 целых чисел
int numbers [] = {7, 12, 8, 12}; // вариант объявления массива, не нужно указывать длину

array[0]= "test"; // добавляем 1 элемент в 0 индекс
for (int i = 0; i < array.length; i++) {
//выводим все значения элементов массива

int[] numbers = new int[]{1, 2, 3, 4, 5}; 
for (int i : numbers){
//вывод через цикл forEach
Arrays.sort(numbers);//сортировка по возрастанию
int c;
for (int i = 0; i < array.length ; i++) {
    for (int j = i ; j < array.length; j++) {
        if (array[i] < array[j]) {
            c = array[i];
            array[i] = array[j];
            array[j] = c;
//сортировка по убыванию
System.out.println(Arrays.toString(array));//вывод на консоль содержимого массива
       int [] array2 = Arrays.copyOf(array, array.length); //копируем содержимое массива в другой целиком
int [] array2 = Arrays.copyOf(array, 4); //копируем первые 4  элемента
int [] array2 = Arrays.copyOf(array, 2,5); //копируем со 2(включительно) по 5(не включительно)
Arrays.equals(array,array2); //сравниваем содержимое массивов
 int[] array = new int[10];

        for (int i = 0; i < array.length; i++)
           array[i] = 10 - i;
// заполнение массива числами от 10 до 1 

array.length; //длина массива