In this article, we shall consider key concepts of the relational data model and relational database constraints.
First, let us consider terms in the relational data model.
For example, a relation schema for student:
student(id, name, phone, address, age, gpa)
student is a relation name. It has six attributes. …
Let’s say we have submitted a pull request to a public repository long ago. That repository’s main branch is updated often since then. Now that repository’s maintainer wanted to merge our pull request but our pull request branch is some number of commits behind their master branch. Therefore we need to update our pull request (branch) without any conflicts.
I had a similar experience.
In this article, I will explain you how to update pull request branch.
Let’s dive in!
Threads share memory and resources (data, code etc.) Threads execute concurrently. Hence, threads can access common resources simultaneously. This may bring us some undesirable outcome.
Synchronization prevents threads from accessing common resources simultaneously. It allows a thread to access a resource at a time.
Each object has a lock. If one thread has gained that object’s lock, the other threads will have to wait until that particular thread releases it. In this way, a thread can access a resource at a time.
We can use synchronized
non access modifier to gain object’s lock. …
Multitasking refers to the execution of multiple tasks simultaneously. Tasks can be programs, processes, and threads. For example, we can play songs on Windows Media Player and edit documents in Microsoft Word simultaneously. Multitasking systems are known as time sharing systems.
This concept is for single CPU (single processor).
Multitasking is the logical extension of multi programming. Multi programming is based on context switching while multitasking is based on context switching and time sharing (time slicing).
Multitasking system executes process on CPU with a timer. Once that timer has finished, it interrupts the current process and switches the process.
Each process executes on CPU until time slice expires or it requires I/O. …
If a system contains more than one processor (CPU) then it is known as multi processor system.
Single processor (single CPU) system executes a process at a time. As multi processor system has more than one processor, it executes more than one process at a time (multi processing simultaneously). So, we can save time.
These processors (CPUs) share memory, power supply, and peripheral devices. Thus, we can save money (we do not need extra peripheral devices, power supply or memory).
Let’s say we have four processes: P1, P2, P3, and P4. …
If a computer runs multiple programs at a time then it is known as multi programming. For example, running Google Chrome and Windows Media Player simultaneously.
This concept is for single CPU (single processor).
Multi programming system executes a process at a time on a single processor concurrently.
Operating System (OS) mainly contributes for multi programming.
Processes are executed by CPU. Processes (jobs) wait at job pool for CPU (processor) allocation in order to execute. CPU selects a process from job pool and executes it.
In a non multi programming system, CPU executes a process until that process requires for an I/O task or an external factor interruption. …
Array is a data structure to store data of same type. Array stores its elements in contiguous memory location. We can store fixed amount of elements in an array.
In Java, arrays are objects. All methods of class Object may be invoked in an array.
Let’s declare a simple primitive type array:
int[] intArray = {2,5,46,12,34};
Let’s try to print it with System.out.println()
method:
System.out.println(intArray);
// output: [I@74a14482
Why Java did not print our array? What happens under the hood?
System.out.println()
method converts the object we passed into string by calling String.valueOf()
. If we look into String.valueOf()
method’s implementation:
public static String valueOf(Object obj) {
return (obj == null) ? "null" : obj.toString(); …
In this article we shall see what actually is Java Collections framework. We shall walk through Oracle Java Documentation to find out what it is!
A collection — sometimes called a container — is simply an object that groups multiple elements into a single unit. — Oracle Java Documentation
Real world examples of collection include poker hand (a collection of cards), a mail folder (a collection of letters) or a telephone directory (a mapping of names to phone numbers).
A collections framework is a unified architecture for representing and manipulating collections. — Oracle Java Documentation
All collections frameworks contain:
Objects in Java are created from inside out.
It goes all the the way up to the Object class, comes down through the hierarchy and initializes all instance variables to create objects.
public class Person {
private String name;
}
In the above code, there is no statement that the Person extends Object but when creating an object, it actually goes inside out. How?
When you don’t define a super class, the compiler inserts one for you.
While compiling this is what actually happens:
public class Person extends Object{
private String name;
}
Now we know how Person extends Object.
Let’s say we have defined a super class for Person then what happens? …
Polymorphism is the ability of an object to take on many forms. That is, at compile time, Java object will be in reference type but at runtime, it will be in runtime type (object type).
Polymorphism in OOP occurs when a super type references a sub type object.
All Java objects are considered to be polymorphic as they share more than one IS-A relationship (at least all objects will pass the IS-A test for their own type and for the class Object).
We can access an object through a reference variable. A reference variable can be of only one type. …
About