Thursday, July 28, 2022

Difference between table scan, index scan, and index seek in SQL Server Database? Example

Hello guys, a good understanding of how the index works and how to use them to improve your SQL query performance is very important while working in a database and SQL and that's why you will find many questions based upon indexes on Programming Job interviews. One of such frequently asked SQL questions is the real difference between table scan, index scan, and index seek? which one is faster and why? How does the database chooses which scan or seek to use? and How you can optimize the performance of your SQL SELECT queries by using this knowledge. In general, there are only two ways in which your query engine retrieves the data, using a table scan or by using an index.

How to find Nth Highest Salary in MySQL and SQL Server? Example LeetCode Solution

Nth Highest Salary in MySQL and SQL Server - LeetCode Solution
---------------------------------------------------------------
Write a SQL query to get the nth highest salary from the Employee table.

+----+--------+
| Id | Salary |
+----+--------+
| 1  | 100    |
| 2  | 200    |
| 3  | 300    |
+----+--------+

For example, given the above Employee table, the nth highest salary where n = 2 is 200. If there is no nth highest salary, then the query should return null.

Wednesday, July 27, 2022

10 Examples of df Command in Linux and UNIX

Hello, In Today’s article we shall be talking about the df command in Linux. The objectives of this article are: What is the df command, and what does it mean? How is it used? I shall be providing 10 different examples or scenarios for it and when to use it

What does df mean?

The meaning of df in Linux is disk-free or disk file system. Which is used to display the file system in the likes of total storage space, available storage space and etc.

Df command in Linux is a command or syntax in Linux that you doing away with it is almost impossible

You may begin to wonder or ask Why or When do You need to use it?

How to use recursive grep command in Linux and UNIX? grep -iR Example tutorial

Hello guys, one of the most common tasks while working on programming projects is finding files containing some specific text like you have your application deployed in the Linux server, and you are migrating your database from one server to another. Now, you want to file all config files and scripts which are referencing your old database using the hostname or IP address, so that you can replace them with an alias. Well, you should always use an alias to connect to the database or any other system, but sometimes it happens you have to use a hostname. Anyway, how do you find all those files containing hostname in your Linux machine? Well, the grep command is here to help you.

Difference between Soft Link vs Hard Links in Linux/UNIX? Answer

Hello guys, if you are looking to find out the difference between a soft link and a hard link in Linux then you have come to the right place. Earlier, I have shared the free Linux courses for beginners and in this article, I am going to explain the soft links and hard links in UNIX operator systems like Linux. There are two types of links in the UNIX system, hard links and soft links, also known as symbolic links or symlinks. Though both points to some other source, there is a lot of difference between them. The most important difference is that a hard link is a direct pointer to the inode of the original file. If you compare the original file with the hard link there won't be any differences between them. 

6 Linux command Examples and One liners Every Programmer Should Remember

Hello guys, Linux is an important skill for any developer or DevOps engineer becuase most of the server-side applications run on Linux boxes. At least you should be familiar with essential Linux commands like ls, cat, ps, top, find, grep, awk, sort, uniq, kill, xargs, curl, lsof, etc. I have shared a lot of useful Linux tutorials in this blog and you can take a look at them to learn about those commands in detail. Today, I am going to share some of the useful Linux one-liners you can use in your day-to-day life. These one-liners are either example of one single command or multiple commands used together to do a certain task like finding duplicate rows in a text file or counting how many times each IP address appear in a text file, much like group by clause of SQL.

How to Find large Files and Directories with size in Linux and UNIX? find + du command Example Tutorial

One of the common problems while working in Linux is finding large files to free some space. Suppose, your file system is full and you are receiving an alert to remove spaces or if your host is run out of space and your server is not starting up, the first thing you do is find the top 10 largest files and see if you can delete them. Usually, old files, large Java heap dumps are good candidates for removal and freeing up some space. If you are running Java applications like core Java-based programs or web applications running on Tomcat then you can remove those heap dump files and free some space, but the big question is how do you find those? How do you know the size of the biggest file in your file system, especially if you don't know which directory it is? We'll try to find answers to some of those questions in this article.

Monday, July 25, 2022

How to send Email with Body and Attachment from Linux Machine? mutt and mailx command Example

One of the common tasks for programmers working in a Linux machine is to send emails and transfer files from Linux machine to Windows machine. While there are utilities like WinSCP which you can use to transfer files between Windows and Linux machine, I generally found using mailx command much easier, especially when you don't have WinSCP or any other utility. But, apart from transferring files between Linux and Windows, there are many more scenarios where you need to send emails from Linux machine, for example, your Java applications are running on Linux like RHEL 5 or RHEL 6 version and you need to send a report of all the clients connecting to your application.

How to set JAVA_HOME and PATH in Linux? Example

Hello guys, welcome to the world of Java application programming. One of the hardest things to mater is not any feature but environment-specific details which nobody teaches. To bridge that gap, I am going to cover a couple of very important environment variables like PATH and JAVA_HOME.  The JAVA_HOME environment variable points to the JDK installation directory and is used by many Java tools and applications like TomcatMaven, Eclipse, NetBeans or IntelliJIDEA, etc. to figure out Java executables as they need Java for running. 

How to backup and load Cron Jobs from a File in Linux and UNIX? Crontab Command Example

Hello guys, If you have been using Linux for some time then you might know about cron jobs. They are the scheduler that can be used to automatically start processes in a Linux box. I have worked on many projects which used cron jobs to start the Java process and environment daily or weekly basis. They are similar to Autosys when it comes to scheduling jobs but cron is a Linux command as opposed to Autosys which is a separate application altogether. In Linux, the crontab command is used for scheduling and automating jobs or processes. You can also use it for loading cron jobs from a file, listing existing cron entries, and editing them. It manages the cron table that is used by the cron daemon in Linux to execute the cron jobs.

How to find swap space and usage in Solaris? Swap Command Example

Swap space in Solaris or any UNIX host is a vital disk space that is used for the swapping process from physical memory (RAM)  to disk. Virtual memory allows a process to run even if physical memory gets full by using swap space (which is located on your hard disk) to swap out memory pages that are not currently in use. This is a very important concept which every programmer and Linux user should know. It is even more important if you are working in IT support or as a system admin because if swap space is full then swapping will fail and no new process will be able to start. 

How to send Logging Messages to SysLog using Log4j2 SysLogAppender in Linux ? Java Example

Sometimes you may want to route your log messages to Syslog in UNIX-based environment like Linux. Since logger allows multiple appenders, you can print the same log messages to a log file, console, and route it to Syslog at the same time. In order to send log messages to Syslog using log4j2, you need to make some changes in your log4j2.xml file. This change is to include the Syslog appender and configure that, once you do that you also need to enable TCP or UDP reception by editing rsyslog.conf file. For faster transmission you can choose UDP protocol and configure a port number on which your Syslog is listening, In our example, Syslog is listening on port 618. Let's see the complete step-by-step guide to configure Syslog logging in log4j logger.

5 Ways to implement Singleton Design Pattern in Java? Examples

Hello guys, While Singleton is anti pattern nowadays and dependency injection is better choice as it helps unit testing, its good to know about Singleton pattern, especially if you are in the business of maintaining large and old code base. This article introduces the singleton design pattern and its 5 implementation variations in Java. You will learn different ways to implement a singleton pattern and understand the challenges of creating a singleton class, like thread-safety issues and serialization issues.

How to use Strategy Design Pattern in Java? Example Tutorial

Hello guys, you might have heard about it, Can you tell me any design pattern which you have used recently in your project, except Singleton? This is one of the popular questions from various Java interviews in recent years. I think this actually motivated many Java programmers to explore more design patterns and actually look at the original 23 patterns introduced by GOF. The Strategy design pattern is one of the useful patterns you can mention while answering such a question. It's very popular, and there are lots of real-world scenarios where the Strategy pattern is very handy. 

Friday, July 22, 2022

10 Examples Of du Command in Linux

 Here, we shall be looking at another command in Linux. The” du” command. Before giving the examples you can use with it I will be explaining the du itself, What is being used for and When to use it, and How to use it

So Firstly, What is DU or What does the command mean?

The full meaning of du is Disk usage. This helps in planning and maintaining the file’s space. The command is used to keep track of any files or directories that are taking up too many spaces in the hard disk drive. Now we shall be taking the examples one after the other.

Thursday, July 21, 2022

3 Examples of for loop in Linux and Bash Script [Tutorial]

Hello guys, if you want to learn how to use for loop in bash or Linux then you have come to the right place. Earlier, I have shared free Linux courses and free bash scripting courses, and today, I am going to share three simple examples of using for loop in Linux.  If you are a Programmer, Software Engineer, or System Administrator working in a UNIX or Linux environment, then you will probably find the shell 'for' loop to be a handy tool for automating simple command-line tasks. This is the single command which has helped me a lot while doing production support and performing operational tasks. 

10 ways to Quit/Exit from Vim Editor in Linux/UNIX? Examples

Hello guys, if you are stuck inside VIM editor and looking for a way to come out then you have come to the right place. In the past, I have shared the free Linux courses and today, I am going to talk about Vim or VI editor, one of the most important tools for people working in Linux. You might not know but many developers struggle to get out of commands like Vim and telnet. I can say that because there was a time when I spend a good amount of time coming out from the telnet window.

10 Example of ps -ef command in Linux and UNIX

Hello guys, It's been a long time since I wrote about the Linux command in this blog. In my last article, I have shared free Linux courses for beginners which many of you guys have liked, that's why I am writing another post on Linux, this time about the "ps" command.  If you have worked on a Linux machine then you are likely to be familiar with the "ps" command. The "ps" command is used to check the process status. It stands for "process statistics" and you can use the ps command to see all the processes and find things like PID which can be used to interact with the process. For example, you can kill a process by passing PID to kill command in Linux as shown here.  

10 Examples of df Command in Linux

Hello, In Today’s article we shall be talking about the df command in Linux. The objectives of this article are: What is the df command, and what does it mean? How is it used? I shall be providing 10 different examples or scenarios for it and when to use it

What does df mean?

The meaning of df in Linux is disk-free or disk file system. Which is used to display the file system in the likes of total storage space, available storage space and etc.

Df command in Linux is a command or syntax in Linux that you doing away with it is almost impossible

You may begin to wonder or ask Why or When do You need to use it?

How to add or view SSL certificate in Java keyStore or trustStore? keytool command examples

The keytool command in Java is a tool for managing certificates into keyStore and trustStore which is used to store certificates and requires during the SSL handshake process. By using the keytool command you can do many things but some of the most common operations are viewing certificates stored in the keystore, importing new certificates into the keyStore, delete any certificate from the keystore, etc. For those who are not familiar keyStore, trustStore, and SSL Setup for Java application Here is a brief overview of What is a trustStore and keyStore in Java

Tuesday, July 19, 2022

How to use PreparedStatement in Java - JDBC Example Tutorial

PreparedStatement is used to execute specific queries that are supposed to run repeatedly, for example, SELECT * from Employees WHERE EMP_ID=?. This query can be run multiple times to fetch details of different employees. If you use PreparedStatement like above then the database assists in query preparation, which is faster and more secure. Such kinds of queries are compiled, and their query plans are cached at the database side every time you execute it, you will get a faster response as opposed to using simple queries via Statement object, like SELECT * from Employees WHERE EMP_ID + emp_id.

How to Create and Start Multiple Threads in Java? - Example Tutorial

Hello guys, Multithreading is one of the biggest strengths of Java, which allows you to divide a task and execute faster by using more than one thread. In order to use multiple threads in Java, you need to first define the task which will be executed by those threads. In order to create those tasks, you can either use the Runnable or Callable interface. If you are just learning Java chose the Runnable interface, it's a simpler one, but if you are familiar with Java multithreading and want to leverage additional features offered by Callable like it can throw an exception and it can also return value, then go ahead and use the Callable interface. Once you have the task ready, you need to create an instance of the Thread class.

How to use wait, notify, and notifyAll in Java? Example Tutorial

When should you use the wait() and notify method in Java is one of the many popular questions about the wait and notify methods from Java multithreading interview questions. One of the reasons for its popularity is that still a lot of Java programmers struggle to explain and write code using wait-notify methods.  Many Java developer only knows some facts about the wait and notify methods like that wait() and notify() are defined in the java.lang.Object class or you cannot call wait() without synchronization, which means without a synchronized block or synchronized method but doesn't really know when and how to use them.

Sunday, July 17, 2022

How to Join and Merge Two ArrayLists in Java - Example Tutorial

You can use the addAll() method from java.util.Collection interface to join two ArrayLists in Java. Since ArrayList implements List interface which actually extends the Collection interface, this method is available to all List implementations including ArrayList e.g. Vector, LinkedList. The Collection.addAll(Collection src) method takes a collection and adds all elements from it to the collection which calls this method like target.addAll(source). After this call, the target will have all elements from both source and target ArrayList, which is like joining two ArrayList in Java. 

What is Iterator in Java? Example

Hello guys, if you are wondering what is Iterator in Java and how does it work? when you are supposed to use Iterator and what advantages or disadvantages it provide over other methods of iterating over Java Collections then you have come to the right place. In the past, I have shared how HashMap works in Java and How Garbage collection works and in this article, I am going to share how Iterator works and how they simplify iteration irrespective of different collection types. You all may know about Java collections. It has many lists, maps, etc in it. Now, you may know how to use the inbuilt LinkedList or any other collection, but once that collection is built, how will you iterate over it? I know you all are thinking of loops.

Tuesday, July 12, 2022

Top 5 Free Microsoft Power BI Online Courses for Beginners to Learn in 2024 - Best of Lot [UPDATED]

Hello guys, if you want to learn Power BI in 2024, one of the leading too for Data Visualization and Business Analytics, and looking for free resources like free online courses, books, and tutorials, then you have come to the right place. Earlier, I shared the best Power BI courses. In this article, I am going to share the best free online training courses to learn Microsoft  Power BI. Many people think that free resources are inferior and just created for marketing reasons, they are somewhat correct but it's not always true. There are many free resources that are even better than paid courses. For example, these free courses have been created by experts and trusted by thousands of developers and tech people who want to learn Power BI. 

Top 5 Gifts You can Buy for Programmers, Coders, and Software Developers in 2024 - Best Gifts [UPDATED]

If you are planning for a surprise gift to your programmer boyfriend and husband this holiday season like Black Friday, Christmas, or New Year, or maybe on his next birthday, but not sure what to gift, then you have come to the right place. In this article, I am going to share some of the best gifts ideas for programmers and developers, gifts that every programmer wishes for. To be honest with you, buying a gift is easy, but finding the right gift is very tough. I have spent countless hours on the internet to find a perfect gift for one of my colleague's husbands, and this article is a result of that research.

Saturday, July 9, 2022

Top 10 Java Multithreading Courses for Beginners in 2024 - Best of Lot [UPDATED]

Hello guys, if you want to learn multithreading and concurrency in Java and looking for the best learning material like books, tutorials, and online courses then you have come to the right place. Earlier, I have shared the best Core Java courses and best data structure and algorithm courses and in this article, I am going to share the best online courses to learn Multithreading in Java. These courses are curated from the best online learning websites like Udemy, Pluralsight, and Coursera and will teach you Java Multithreading from scratch. But, before we get to the best courses that you can use to learn more about multithreading in Java, let me tell you what multithreading exactly is.  

Friday, July 8, 2022

Top 10 Java 8 Tutorials, Classes, and Courses in 2024 - Best of Lot [UPDATED]

Hello guys, if you want to learn Java 8, in a particular lambda expression, Stream API, method reference, and new Date and Time API, and looking for the best resources then you have come to the right place. Earlier, I have shared the best  Spring Framework courses and free Java courses and today, I am going to share the best tutorials to learn Java 8 features. It's a long time since Java 8 was released, and there are so many Java 8 tutorials are written by Oracle, Java bloggers, and other people, but which should you read? Which tutorials are worth your time? 

Thursday, July 7, 2022

How to convert Java object to JSON String using Gson? Example Tutorial

If you are a Java or Android developer and learning JSON to support JSON format for your project and looking for a quick and simple way to convert your Java object into json format then you have come to the right place. In this article, I'll teach you how to convert a Java object to a JSON document using Google's Java library called Gson. This library allows you to convert both Java objects to JSON String and a JSON document to Java objects. So, let's first do some serialization. Serialization in the context of Gson means mapping a Java object to its JSON representation.

Top 5 Best Free Courses to learn JDBC Java Programmers in 2024 - Best of Lot [UPDATED]

Hello guys, If you are a Java programmer and looking for some free and best JDBC courses to start learning database access in Java, then you have come to the right place. In this article, I am going to share some of the free and paid online JDBC (Java Database Connectivity) courses from popular sites like Udemy and Pluralsight to give you a head-start in your long journey of writing real-world Java application which interacts with the database. Since Data is the utmost important part of any Java application, it's imperative to have a good knowledge of how to interact with the Database from Java application, and JDBC is the first step in that direction.

Monday, July 4, 2022

Top 5 MEAN stack online Courses to Learn Web Development in 2024 - Best of Lot

Hello guys, if you want to learn MEAN stack to become a full stack web developer, you have come to the right place. I have been sharing valuable courses to learn modern tech stack like in the past, I have shared the best courses to learn MERN stack, and in this article, I will list the top 5 MEAN stack courses that explain every concept nicely and properly. The MEAN (Mongo, Express, Angular, and Node) stack is undoubtedly the most popular software stack in full-stack web development. The demand for full-stack developers has increased tremendously in recent years. This pandemic has also given the digital push to many companies, which means the demand will only increase. 

Why String is Immutable or final in Java - 5 Reasons

There is hardly any Java Interview, where no questions are asked from String, and Why String is Immutable in Java is I think most popular Java String question. This question is also asked as Why String class is made final in Java or simply, Why String is final. In order to answer these questions, Java programmer must have a solid understanding of how String works, what are special features of this class, internal structure and implementation of String and some key fundamentals. The String class is a God class in Java, It has got special features which is not available to other classes like String literals are stored in string pool

Saturday, July 2, 2022

[Solved] How to remove duplicate elements from Array in Java? Example

This is one of the common technical interview questions which are asked to entry-level programmers and software engineers. There are also a lot of variants of how do you remove duplicates from an array in Java, like sometimes the array is sorted, and other times it's not sorted or unsorted. Sometimes, the Interviewer just spends more than half of the interview on this question by progressively making it more difficult by imposing new constraints like removing duplicate elements in place or without using any additional data structure, etc.

Difference between Array vs ArrayList in Java

What is the difference between Array and ArrayList is quite a common question among beginners especially those who started coding in C and C++ and prefer to use Array? Both Array and Array List are used to store elements, which can be either primitive or objects in case of Array and only objects in case of ArrayList in Java. The main difference between Array vs ArrayList in Java is the static nature of the Array and the dynamic nature of ArrayList. Once created you can not change the size of Array but ArrayList can re-size itself when needed. 

6 Free Courses to learn Machine Learning and Deep Learning in 2024 - Best of Lot

Hello guys, if you want to learn Machine learning and Deep learning in 2024 and look for the best online courses and tutorials, you have come to the right place. In this article, I will share some of the best free classes to learn Machine learning and Deep learning online. By the way, If you are thinking of learning Data Science, Machine learning, or Deep learning, you are not alone; more and more people are starting with these advanced skills worldwide. I have seen a lot of interest from Indian engineers in machine learning and the Artificial intelligence space. They are totally caught up with the craze of developing programs that can recognize numbers, alphabets, vehicles, and several other image scanning stuff.

Top 5 Free Courses to learn Node.js in 2024 - Best of lot

Node JS has completely changed the way JavaScript is used for development. Earlier JavaScript was considered as a client-side language because it runs on a browser and is mostly used for client-side validations, animations, and interaction. Node.js takes that to the next level by allowing JavaScript to run on a server-side, which means you can now write JavaScript applications that can execute without a browser. Node JS uses Google Chrome's execution engine and asynchronous processing to do this. All you need to is include a node.js script in your application, and you are ready to create server-side applications in JavaScript, which wasn't possible until a few years back.