No doubt that Data structure and algorithms are an integral part of any Programming job interview, including Java, C++ or any other programming language. In fact Data structure and algorithms are quite a favorite one and all top notch companies including Google, Microsoft, Amazon and investment banks like Goldman Sachs, Citigroup, Barclays, Morgan Stanley or J.P. Morgan focus extensively on data structure and algorithms, while hiring both senior and mid-level developers in Java, C++, and C# positions. When I shared some traditional, popular, and more frequently asked questions on Data structure and Algorithms in my earlier article, I received a lot of feedback to share some practical, scenario-based questions on data structure e.g. which kind of data structure will you use in a particular scenario and why.
Stack and Queue are two of important data structures in the programming world and have a variety of usage. As opposed to the array and linked list, which are considered as a primary data structure, they are a secondary data structure which can build using an array or linked list. You can use Stack to solve recursive problems and Queue can be used for ordered processing. The difference between Stack and Queue Data structure is also one of the common questions not only in Java interviews but also on C, C++, and other programming job interviews. Well, main difference comes the way these data structures are used, Stack is LIFO (last In First Out) data structure, which means the item which is inserted last is retrieved first, similar to a stack of plates in a dinner party, where every guest pick up the plate from the top of stack.
Every trade has their tools, and Java programming is no exception. In fact, good knowledge of tools and mastery of using them, saves a lot of time in design, development, testing, debugging, and troubleshooting any production issue. In order to become a good developer, you must know right tools for right jobs. A developer without tools and tricks are like a toothless lion, hence it's very important that you devote some time on learning tools required for your day to day job. Many developers think that learning an IDE like Eclipse, NetBeans or IntelliJ is enough, but that's just the start of the process. No doubt that IDEs are the most important tool ever created for programmers but they are not the solution for everything.
There are a couple of algorithms exists to reverse a singly linked list in Java e.g. You can use the three-pointers approach or solve this problem using a stack, or simply using recursion without the external stack. As I had pointed out on the earlier post about linked list, that reversing a linked list is one of the most popular data structure interview question, based on linked list, which means, you just can't afford to prepare this one, before going for any programming interview. Despite being so common, It's not easy to solve this problem on the fly. Many Java programmer struggles to reverse a linked list using both iteration and recursion, which makes this question very useful for filtering programmers who can code and who are not so good with coding. Indeed, this is one of the confusing algorithms to understand and it's not easy to grasp, especially if you haven't practiced linked list based questions e.g. finding middle node of linked list in one pass or inserting and removing an element from linked list data structure.
Scala is a programming language which aims to provide best of both object-oriented programming and functional programming world. It not only allows you to construct elegant class hierarchies for maximum code reuse and extensibility but also allows you to implement their behavior using higher-order functions and other functional programming technique. It is touted as one of the languages which can probably take over Java, though it didn't happen especially after Java 8 release which also provides some functional programming tools to Java e.g. lambda expression and stream. Nevertheless, Scala is a good language and created by following best practices from several other programming languages including Java. Scala is an acronym for “Scalable Language”. This means it is designed by keeping scalability in mind. Many companies e.g. Twitter, LinkedIn, and Intel uses it for their mission-critical application.
Today, we are going to see another common and interesting SQL interview question, what is the difference between SQL, T-SQL and PL/SQL? It is also one of the most common doubt among SQL beginners. It's common for programmers to think that why there are many types of SQL languages, why not just single SQL across DB? etc. Well, let's first understand the difference between SQL, T-SQL and PL/SQL and then we will understand the need of these dialects. SQL is standard for querying, inserting and modifying data in relational database. It is categorized into DDL and DML and powerful enough to create a database objects e.g. table, view, stored procedure and can perform CRUD operation (SELECT, INSERT, UPDATE, and DELETE) query.
If you have used Hibernate in past then you know that one of the strongest points of Hibernate framework is caching, which can drastically improve the performance of Java application's persistence layer if configured and used correctly. Hibernate provides caching at many levels e.g. first level cache at Session level, second level cache at the SessionFactory level, and query cache to cache frequently executed SQL queries. The first level cache minimizes database access for the same object. For example, if you call the get() method to access Employee object with id = 1 from one session, it will go the database and load the object into memory, but it will also cache the object in the first level cache.
Many times you get a list of values which you want to check in the database to confirm if they exist in your tables or to get more information bout them. For example, you got a list of 100 stocks and you want to check their last day closing prices in the database. The problem arises when values to be searched are Strings e.g. VARCHAR or CHAR because VARCHAR values need to enclosed in the single quotes in most of the database e.g. SQL Server, Oracle or MySQL. If number of values are less than 5 then it make sense to add single quotes around them and separate them by comma manually so that you can use then on IN clause of your SQL query, but if it's more than 5 e.g. 50 or 100 then manually enclosing them into single quotes will take a lot of time and most importantly programmers are not supposed to do such silly stuff manually.
Lambda expression allows you to reduce code compared to anonymous class to pass behaviors to methods, method reference goes one step further. It reduces code written in a lambda expression to make it even more readable and concise. You use lambda expressions to create anonymous methods. Sometimes, however, a lambda expression does nothing but call an existing method. In those cases, it's often clearer to refer to the existing method by name. Method references enable you to do this; they are compact, easy-to-read lambda expressions for methods that already have a name.
If you an experienced programmer and know how to write SQL queries and database fundamentals but want to take your SQL and database skills to next level then you have a come to the right place. This is the second article about SQL books, In the first part, I have shared some of the best SQL books which are essential to learning SQL queries and fundamentals of database e.g. normalization, indexing, and other design stuff, if you haven't read it yet, I suggest to do it now. You will find some amazing book to start learning SQL. In this article, I am going to share some of the best books to learn advanced SQL programming, which can help you to write better SQL queries and understand how database process those queries.
The stack is one of the popular data structure which supports LIFO (Last In First OUT) operation. Due to LIFO advantage, you can use stack data structure to convert a recursive algorithm to an iterative one. Stack data structure is very easy to implement using an array or linked list, but you don't have to implement it by your own because Java already provides a Stack implementation in java.util.Stack class. This class is a subclass of the Vector class and you should use it whenever you need Stack for your production code, there is no point inventing the wheel again when the focus is on developing your application. At the same time, as a programmer and coder, you should also know how to implement your own stack by using a basic data structure like an array or linked list.
Today I am going to discuss one of the frequently asked programming interview questions to find the largest and smallest number from an integer array. This question is commonly asked on telephonic interviews and the first round for screening candidates. It's one the same league of other frequently asked coding question e.g. Fibonacci, Palindrome, Prime, and Power of two checks. They are easy but can feel difficult during the interview because of pressure. You can further evaluate candidate's problem-solving skill by asking him to solve the problem by a different way e.g. if he solves the problem using a loop then ask him to do it without the loop. If he knows recursion he can do it, but if he has just mugged the answer, he won't be able to do it.
In one word, we use Threads to make Java application faster by doing multiple things at same time. In technical terms, Thread helps you to achieve parallelism in Java program. Since CPU is very fast and nowadays it even contains multiple cores, just one thread is not able to take advantage of all the cores, which means your costly hardware will remain idle for most of the time. By using multiple threads, you can take full advantage of multiple cores by serving more clients and serving them faster. Since, in today's fast-paced world, response time matters a lot and that's why you have multi-core CPUs, but if your application doesn't make full use of all resources then there is no point adding them, multi-threading is one way to exploiting huge computing power of CPU in Java application.
Labels: Java multithreading Tutorials
The curl is one of the essential commands to send HTTP requests from UNIX and Linux operating System. curl command is part of the cURL package and it's not just useful to send HTTP request but also allows you to transfer file using FTP and send mail using SMTP. The cURL utility supports many protocols including DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAP, LDAPS, LDAP, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMTP, SMTP, Telnet, and TFTP. It also supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, HTTP/2, cookies, user+password authentication (Basic, Plain, Digest, CRAM-MD5, NTLM, Negotiate and Kerberos), file transfer resume, proxy tunneling and more. It's particularly useful if you are working with web services.