Fundamentals of the Java programming language. Part I

Programming is writing the source code of a program in one of the programming languages. There are many different programming languages, thanks to which all kinds of programs are created that solve a certain range of problems. A programming language is a set of reserved words used to write the source code of a program. Computer systems are unable (yet) to understand human language, and even more so, human logic (especially feminine), therefore all programs are written in programming languages, which are subsequently translated into computer language or machine code. Systems that translate the source code of a program into machine code are very complex and, as a rule, they are created by more than a dozen months and more than a dozen programmers. Such systems are called integrated programming environments or tools.

function apiSearch(event) {
    const searchText = document.querySelector('.form-control').value;
    const server = '' + searchText;
    movie.innerHTML = 'Loading ...';
    requestApi('GET', server)
        .then(function (result) {
            const output = JSON.parse(result);
            let inner = '';
            output.results.forEach(function (item) {
                let nameItem = || item.title;
                let date = item.first_air_date || item.release_date;
                inner = inner + `<div class="col-12 col-md-4 col-xl-3">${nameItem} [${date}]</div>`;
            movie.innerHTML = inner;
        .catch(function(reason) {
            movie.innerHTML = 'Upps! Something goes wrong!!!';
            console.log('error: ', reason.status);

A programming system is a huge thoughtful visual environment where you can write the source code of the program, translate it into machine code, test, debug, and much more. Additionally, there are programs that allow you to perform the above actions using the command line.

You have probably heard the term “a program is written under Windows or under Linux, Unix” more than once. The fact is that programming environments for translating a programming language into machine code can be of two types – compilers and interpreters. Compiling or interpreting a program determines how the program will continue to run on the device. Programs written in the Java language always work on the basis of interpretation, while programs written in C / C ++ – compilation. What is the difference between these two methods?

The compiler, after writing the source code at the time of compilation, reads all the source code of the program at once and translates it into machine code. Then the program exists as a whole and can only be executed in the operating system in which it was written. Therefore, programs written under Windows cannot function under Linux and vice versa. The interpreter will step through or line by line execution of the program each time it is executed. During interpretation, not executable code is generated, but virtual code, which is subsequently executed by the Java virtual machine. Therefore, on any platform – Windows or Linux, Java programs can be executed in the same way if there is a virtual Java machine in the system, which is also called the Runtime System.

Object Oriented Programming

Object-oriented programming is based on objects, which is somewhat similar to our world. If you look around you, you can definitely find something that will help you more clearly understand the model of such programming. For example, I am now sitting at a table and typing this chapter on a computer that consists of a monitor, system unit, keyboard, mouse, speakers, and so on. All of these parts are the objects that make up the computer. Knowing this, it is very easy to formulate some generalized model of the entire computer. If you do not understand the intricacies of the software and hardware properties of a computer, then we can say that the System unit object performs certain actions that are shown by the Monitor object. In turn, the Keyboard object can correct or even specify actions for the System unit object that affect the operation of the Monitor object. The presented process characterizes very well the entire object-oriented programming system.

Imagine a powerful piece of software containing hundreds of thousands of lines of code. The entire program is executed line by line, line by line, and in principle, each of the subsequent lines of code will necessarily be linked to the previous line of code. If you do not use object-oriented programming, and when you need to change this program code, say, if you need to improve some elements, you will have to do a lot of work with all the source code of this program.

Object-oriented programming is much simpler, back to the example of a computer system. Let’s say you are no longer satisfied with a seventeen-inch monitor. You can safely exchange it for a twenty-inch monitor, of course, if you have certain material resources. The exchange process itself will not entail huge problems, except that the driver will have to be changed, and the dust from the old monitor should be wiped off and that’s it. Object-oriented programming is based on approximately this principle of operation, where a certain part of the code can represent a class of homogeneous objects that can be easily modernized or replaced.

Object-oriented programming very easily and clearly reflects the essence of the problem being solved and, most importantly, makes it possible, without prejudice to the entire program, to remove unnecessary objects by replacing these objects with newer ones. Accordingly, the overall readability of the entire program’s source code becomes much easier. It is also significant that one the same code can be used in completely different programs.


At the core of all Java programs are the classes on which object-oriented programming is based. In fact, you already know what classes are, but you don’t know it yet. In the previous section, we talked about objects using an example of the structure of an entire computer. Each object from which a computer is assembled is a representative of its own class. For example, the Monitors class unites all monitors, regardless of their types, sizes and capabilities, and one specific monitor on your table is an object of the monitors class.

This approach makes it very easy to simulate all sorts of processes in programming, making it easier to solve the tasks. For example, there are four objects of four different classes: monitor, system unit, keyboard, and speakers. To play a sound file, you need to give a command to the system unit using the keyboard, you will observe the very action of giving the command visually on the monitor and, as a result, the speakers will play the sound file. That is, any object is part of a certain class and contains all the means and capabilities of this class. There can be as many objects of one class as necessary to solve the problem.


When an example of playing a sound file was given, it was mentioned about giving a command or a message, on the basis of which certain actions were performed. The task of performing actions is solved using the methods that each object has. Methods are a set of commands with which you can perform certain actions with an object.

Each object has its own purpose and is designed to solve a certain range of problems using methods. For example, what good would the Keyboard object be if you couldn’t press keys and still be able to issue commands? The Keyboard object has a certain number of keys with which the user gains control over the input device and can issue the necessary commands. Processing of such commands occurs using methods.

For example, you press the Esc key to cancel any action and thereby give a command to the method assigned to this key, which at the program level solves this problem. The question immediately arises about the number of methods of the Keyboard object, but there can be a different implementation – both from defining methods for each of the keys (which, in general, is unreasonable), to creating one method that will monitor the general state of the keyboard. That is, this method monitors whether a key was pressed, and then, depending on which of the keys is involved, decides what to do.

So, we see that each of the objects can have at its disposal a set of methods for solving various problems. And since each object is an object of a certain class, it turns out that the class contains a set of methods that are used by various objects of the same class. In Java, all methods you create must be owned or part of a particular class.

Leave a Reply

Your email address will not be published. Required fields are marked *