Engineering Blog
11 subscribers
69 photos
76 links
Software Engineer @ EPAM Systems
CS @ Millat Umidi University

Talks about:
๐Ÿ“— OS
๐Ÿ“• Networking
๐Ÿ“™ Backend Engineering
๐Ÿ“˜ RDBMS & NoSQL
๐Ÿ“• DS & ALGO
Download Telegram
Channel created
Channel name was changed to ยซasldev ๐Ÿ–ฅยป
Bismillah!
Taxminan 3 soatda bugungi leetcode daily challengeni yechdim.Alhamdulillah.
Program vs Process vs Thread

Program - is an executable file that contains set of instructions.It is stored passively on disk.

Process - When the Program is loaded into the memory and is active, it becomes Process.It will require some resources, such as counter, stack and etc..

Thread - is the smallest unit of execution within a process.One process can have one or more Threads.

e.g. In your laptop, you have Microsoft Word (Program).When you click it, it will be opened (Process).When you are writing on doc (Thread).
JDK vs JRE vs JVM

Let's imagine a case where we can use above terms. Basically in programming we have two types of people:
โ€ข user
โ€ข developer

For user, to run a compiled java programs (jar files), they only need JRE (Java Runtime Environment). JRE contains necessary libraries and JVM (Java Virtual Machine) to run a compiled Java programs.

Simply, JRE is for running compiled Java programs.

For developer however, they need JDK (Java Development Kit), because it contains necessary tools to create java programs. For example, debugger and much more.

JVM is a machine that takes .class files and turns them into machine specific instructions that finally CPU process.
Leetcode2231. Largest Number After Digit Swaps by Parity

Problem Description: You are given a positive integer num. You may swap any two digits of num that have the same parity (i.e. both odd digits or both even digits).

Return the largest possible value of num after any number of swaps.
Platform Independence

Java is a platform independent language. It follows, write once, run anywhere. How does Java achieve this?
Well, with the help of JVM. Basically, JVM takes .class file and turns it into machine specific code.Therefore, whenever we install jdk or jre, we choose OS that we are running on.
CLASSLOADERS

What is classloaders?

Whenever we built a project, we often use calsses. It might be our own classes or classes that java provides. When we run our program, classloaders try to find the classes that we are using. If there is no classes that we are looking for, java throw ClassNotFoundException.

In Java we have three types of classloaders:
โ€ข system - search from classpath
โ€ข extention - search from ext files
โ€ข bootstrap - search from
Channel name was changed to ยซasldev | javaยป
String vs StringBuffer vs StringBuilder

String is a sequence of characters. In Java Strings are object and immutable. It means, once you create a string, you cannot change its' value. If you want to modify a string, instead of modifying it will create a new string. String objects are stored inside string constant pool.

StringBuffer is a mutable thread safe class that is used to modify strings.

StringBuilder is a mutable, not thread safe class that provide implementation for modifying string.
What is the data type of x * y?

short x = 10; short y = 3; var z = x * y;
Anonymous Quiz
33%
short
50%
int
0%
long
17%
code doesn't compile
Wrapper classes

Even though java is Object Oriented Programming Language, we have 8 primitives in Java:
โ€ข byte
โ€ข short
โ€ข int
โ€ข long
โ€ข float
โ€ข double
โ€ข char
โ€ข boolean

Primitives are stored in stack. If we want to use collection classes, we need objects, we can not use primitives there. Therefore, we have wrapper classes for each primitives.
Implicit and Explicit Casting

Casting is an event that happens when we change the data type of particular object or primitive to its corresponding data type.
Implicit casting happens automatically. For example:
int a = 5;
long b = a; //implicit casting
Explicit casting do not happens automatically rather we have to explicitly do it:
long a = 5;
int b = a; //error
int b = (int) b; //explicit casting
Interface vs Abstract Class

1.We implement one or more interfaces but we can only extend one class.Because java do not allow multiple inheritance.
2.while creating variables or methods inside Abstract Class we can use any acces modifiers, but in interface the variables are by default public final.
Since java 8, we can create default methods inside interface.
3.Abstract classes are faster than interfaces as interface need to search overridden methods.
Let's talk about ACID (:

Atomicity -
Either execution is complete or not, there is no partial execution.

Consistency -
When you want to send $100 to your friend but you only have $40, in simple case after execution you end up having $-60 in your balance. According to the rule Consistency, in such case the transaction should not be executed, because you don't have enough money.

Isolation -
Imagine a case where you send $100 to your friend and it takes some time to increase your friend's balance. In such cases, even though you send money, you should see the old balance that you had. Balance should be updated only when your friends get the money that you send.

Durability -
You send $100 to your friend and see the check of successful execution and at that time the server shut downs. When you come back if you see you old balance it means The execution is not durable
1475. Final Prices With a Special Discount in a Shop

#dailyleetcode