Difference between var, val, and def in Scala

This is one of the frequently asked questions from Scala interviews. Even though both var and val keyword is used to declare variables in Scala there is a subtle difference between them. A var is a variable. It’s a mutable reference to a value. Since it’s mutable, its value may change through the program lifetime. On the other hand, val keyword represents a value. It’s an immutable reference, meaning that its value never changes. Once assigned it will always keep the same value. It’s similar to a final variable in Java or constants in other languages. It's also worth to remember that the variable type cannot change in Scala. You may say that a var behaves similarly to Java variables.

10 Free Java 8 Certification Sample Questions - OCAJP8 and OCPJP8 - 1Z0-808 and 1Z09 dumps

If you are preparing for Oracle Java SE 8 Certifications e.g. OCAJP8 and OCJP8, also known as exam 1Z0-808 and 1Z0-809 and looking for some free practice tests then you have come to the right place. In this article, I am going to share some of the best OCAJP 8 and OCPJP 8 mock tests available for free of cost online, so that you can check your speed and accuracy before the real exam. These tests are not just useful for Oracle's Java OCA and OCP certification but also for upgrade exams like OCJP 8 upgrade exams with code 1Z0-810 and 1Z0-813, upgrade to Java SE 8 from Java 6 and prior version. Many of these practice tests are like web simulator where you need to solve a relatively small number of questions within 45 to 60 minutes. The web simulator also includes timer so that you can finish these free mock tests on time.

Binary Tree Post Order Traversal in Java Without Recursion - Example Tutorial

In the last article, I have shown you how to implement post order traversal in a binary tree using recursion and today I am going to teach you about post order traversal without recursion. To be honest, the iterative algorithm of post-order traversal is the toughest among the iterative pre-order and in-order traversal algorithm. The process of post order traversal remains same but the algorithm to achieve that effect is different. Since post-order traversal is a depth-first algorithm, you go deep before you go wide. The left subtree is visited first, followed by right subtree and finally the value of a node is printed. This is the reason why the value of root is printed last in the post-order traversal algorithm.

How to Prepare for Java Certifications like OCAJP, OCPJP, or OCEJWCD?

No doubt that Oracle's Java certification is one of the most valuable certification for IT industry and helps you to get a better job, a better pay, and a better rise in your current salary. It also improves your recognition and job prospects because many big clients demands certified Java programmers for their mission critical applications. Because of huge popularity and usefulness, many Java developers and computer science graduate aspire for Java certifications. I often receive queries like, what is the best way to prepare for Java certifications like OCAJP or OCPJP? or I am already coding in Java, do I need to prepare explicitly for this exam to do well or my Java development experience is enough? I have 5 years of experience in Java, do I need to prepare for OCAJP 8 or OCPJP 8 exam? etc.

Top 5 Books Java 8 Certifications - 1Z0-808 (OCA) and 1Z0-809 (OCP)

In order to become a Java 8 Certified developer, you need to pass two exams, the OCAJP 8 exam with code 1Z0-808 and the OCPJP8 exam with code 1Z0-809. You will not be a Java SE 8 certified programmer if you just pass the OCAJP8 exam. In order to prepare for both these exams, you need to choose a good study guide and a good mock exam simulator, apart from writing programs on daily basis. Since there are a lot of demand for Java 8 certified professionals across the world, it seems to be a good opportunity to change your career path by learning Java 8, if you are doing some boring IT work and wants to become an application developer. The Java certifications will provide you both knowledge and competitive edge over other candidates who are applying for same Java developer job.

Top 10 Free Python Programming Books - Download PDF or Read Online

Every Programmer loves free eBook, even more, if it comes from renowned technical book publishers like Oreilly or Manning. In the last article, I have shared some of the best free Java programming books and today I am going to share some of the equally best free Python Programming books. These books are not illegal copies which are uploaded into the internet, but they are the legal copies, made free by their author and publishers. Though these are not full-fledged books but concise eBooks, they are very informative and comprehensive enough to learn things like Data Science and Functional programming in Python.

How to convert JSON String to Java Object - Gson/JSON Deserialization Example

In the last article, you have learned how to convert a Java object to JSON String and in today's article, you will learn the opposite, i.e. converting a JSON String to Java object. The first example was known as JSON serialization example and this one is known as JSON deserialization because we are creating a Java object from a String. The idea is very similar to classical Serialization in Java where you convert a Java object to another binary format which can be transported over the network or can be saved in the disk for further usage. That's why the process of converting a Java object to JSON is known as serialization and converting a JSON document to Java object is known as De-Serialization. You can use any JSON library to perform serialization and de-serialization e.g. Jackson Databind, Gson, or Json-simple.  In this program, I'll show you how to use Gson to create a Java object from given JSON String.

How to convert Java object to JSON String - Gson Java/JSON Serialization Example

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 JSON document using Google's Java library called Gson. This library allows you to convert both Java object to JSON String and a JSON document to Java object. So, let's first do some serialization. Serialization in the context of Gson means mapping a Java object to its JSON representation. In the real world, the data can be really complex with lots of attributes and nested with composed object but for now, we'll start with a class which just contain few value attributes e.g. String, int and boolean.

Java Program to calculate Perimeter/Circumference of Circle

One of the common programming exercise for beginners is to write a program to calculate the perimeter or circumference of a circle in Java. This exercise is not just common in Java but also on other programming language courses e.g. C, C++ or Python. I first did this exercise on C++ long ago, but that time the joy of a working program was something different. I was quite happy to see my program compiled without error and can print the correct circumference after entering radius. That program taught me how to take input from a user and how to display output into the console, I didn't know about how to create methods to encapsulate code. For us, only main method matters at that time. Anyway, let's focus on the job in hand i.e. how to find the circumference of Circle of given radius. You have to accept radius from the user and show the output to console.

4 Differences between ISNULL vs COALESCE in SQL Server

Even though both ISNULL() and COALESCE() function provides alternate values to NULL in SQL Server e.g. replacing NULL values with empty String, there are some key differences between them, and the key difference between them is that  COALESCE() is a standard function but ISNULL() is a SQL Server specific, which means it's not guaranteed to be supported by other database vendors like Oracle, MySQL or PostgreSQL. But, perhaps the most important difference between them is that COALESCE is more flexible and powerful than ISNULL(). With ISNULL(), you can only provide one alternate value but with COALESCE you can provide more than one e.g. if col1 IS NULL then take value from column2, if that is NULL then take the default value. Btw, that's not the only differences, there are three key differences between ISNULL() and COALESCE() which we will explore in this article.

How to convert Java 8 Stream to Array or ArrayList - Example Tutorial

It's relatively easy to convert a Stream to an array in Java 8 by using the toArray() method of java.util.Stream class. By using this method you can convert any type of Stream to a corresponding array e.g. a Stream of Strings can be converted into an array of String, or a Stream of integers can be converted into an array of Integers. The Stream.toArray() method is also overloaded, the one which doesn't take any parameter returns an Object[] which might not be very useful, particularly if you want to convert Stream of T to array of T. On the other hand, the overloaded version of toArray(IntFunction[] generator) returns an array containing the elements of this stream, using the provided generator function to allocate the returned array, as well as any additional arrays that might be required for a partitioned execution or for resizing.

SOAP and RESTful - Best Books to Learn Web Service in Java

If you are a Java developer and want to learn how to develop Web Services in Java, both SOAP and RESTful, but confused on where to start, then you have come to the right place. In this article, I am going to share some of the best books to learn about both SOAP and RESTful web services in Java. If you are not familiar with Web Services, it's way to expose the services provided by your application to other developers and application. For example, if your system provides weather information then the user can go and check whether manually by looking at the Web GUI built using HTML, CSS, and JavaScript, but by exposing the same information using Web services, you allow a programmer to display as they want.   A programmer can invoke your web service from a smartphone application and show weather related information in a weather app. The web service really makes your services more accessible and opens a new way to show the information to different users.

How to add JAR file in Eclipse Project Build path - External dependency

In this Java Eclipse tutorial, I will show you two ways to add external JAR files in Eclipse Java projects. Many times we need to use external JAR files in our Java application for different needs e.g. for general purpose you may use Google Guava or Apache Commons. If you are using Spring or Hibernate framework then you need their JAR files as well. In order to use any third-party library or framework, we have to add their JAR files in the classpath, to compile and run our Java programs. Since Eclipse is the most popular IDE for developing Java applications, it's important to know how you can add external JARs into your Java project's build path. For example, suppose, you have downloaded Apache commons JAR file from the internet and wants to add that file to your Java project. In order to use classes and methods from that library, your project must reference those and this is what we will learn here.

Top 10 OCAJP and OCPJP Exam Simulators for Java Certifications

There is no doubt that exam simulators play an important role in preparing for any Java certification e.g. OCAJP, OCPJP, OCEJWCD,   OCMJEA exams. In fact, they are one of the most important pillars because choosing a good exam simulator with a good book is generally the success mantra of many Java certification aspirants. The exam simulators prepare you well for exams by presenting the level of questions you can expect in real exams. They provide the much needed practice in exam like environment to gauge your speed and accuracy. I have personally seen the difference of 30% in score between people who do a lot of mock exams and who just goes without practicing mock exams. Candidates make more mistakes when they first took exams and by participating in mock tests, you train your mind to do fewer mistakes. They also help you to better handle the time pressure of real exam.

2 Best Books to Learn Hibernate for Java Developers

Hibernate is the leading ORM (Object to relational) framework in Java world used to implement persistence layer of enterprise Java applications. It was one of the first Java frameworks on ORM persistence and exists even before the Java Persistence API was introduced. It has since then implement JPA interfaces and you can use Hibernate as one of the JPA implementation. In fact, it is one of the most popular JPA implementation in Java world. I receive a lot of email about books and tutorial to learn Hibernate, especially from intermediate Java developers, who has a couple of years of experience in Java but new to Hibernate. It is also a very useful skill to have on your resume because they are a lot of companies who are using Spring and Hibernate to developer enterprise Java application. So if you are looking for a job in Java world, particularly as Java web development role learning both Spring and Hibernate can help you to get your dream job.

12 Advanced Java programming books for Experienced developers - Part 2

This is the second part of 12 must read advance Java programming books for intermediate and experienced Java programmers. In the first part, I have shared books to learn and master concurrency, performance, design patterns, and Java collection framework. In this part, I will talk about more advanced concepts e.g. security, Java 8, best practices etc. As an experienced Java developer, a lot is expected from you. Junior developers look at you for guidance and project managers look at you to solve problems and bail them out at key junctures. If you don't have solid knowledge of the various aspect of software development, testing, deployment, and documentation, you won't be able to do your job properly and rise in your career.