Why do we teach Java differently?

Why do we teach Java differently?

If you are planning to attend a Selenium course from Techcanvass, you will soon notice that we teach Java in a non-traditional way? Why do we teach Java differently?

Learning Java has always been a psychological barrier for many manual testers and that prevents them from getting into automation testing.

At Techcanvass, we have first hand experience of the challenges faced in learning java and selenium. In this article, we are going to explain our approach of teaching Java, which is easier and quicker for the students.

The labyrinth way

Labyrinth approach to learn java

I hope some of you might remember this game of labyrinth. In this game, you enter from the entry point find your way out. Do you know what is the best way to play this? Think about it, we will come back to it.

To understand the approach to learn java, let’s take the instance of learning How to speak English (if it’s not your mother tongue) ?. Do you remember, how did you learn English in schools?

Learning English, in schools, involved learning of grammar, compositions, structure of sentences etc. The entire process takes several years before you become comfortable with English. But this approach is fine if you are learning it as an academic course.

Let’s consider the case when your company is sending you to Germany for a two-year stint. As a resident there, you must be able to communicate in German else you will face a tough time. Most of the people there,  speak German.

So, how much time will you get to learn German?

You will get a month or at the most couple of months to learn that. Believe me, it’s absolutely impossible to learn German completely in that period. So what do you do? You need to speak that language to order food or get your daily chores performed.

Have you seen English Vinglish movie where Sridevi attends a class to learn English? Even though that was just a movie, we have similar classes in India as well and they are doing a great job of helping people speak English. These institutions make you speak English in just a few months. Even British Council is conducting such courses in India

So how does this work? This is where labyrinth approach comes into picture. In this approach we reverse the normal learning process.

Reversing the learning process

Coming back to our labyrinth….Do you that that it’s easier to finish that game if we start from the end rather than starting from the start. Spoken English or German institutions follow the same approach. This is also known as functional learning approach.

In this approach, we start from the end. Let’s take an example of learning spoken English using this approach. In this approach, we start with a situation rather than starting with grammar.

Consider the scenario: You have to go and buy a pizza and converse with the pizza guy in English. The trainer will show you the conversation script as follows:

You: I want a veg pizza? How much does that cost?

Pizza Guy: It costs 350 bucks

You: Ok. Give it.

Pizza Guy: You want to have it here or take away.

You: I want to have it here.

The trainer, then goes on to explain the patterns and structure of the sentences and its usage (Only relevant piece of grammar). More examples on the same pattern helps the students learn the situational use faster. This is the approach used for learning any other foreign language. Consider this:

Every language is a foreign language other than your mother tongue, did you need to learn the grammar for your mother tongue before you started to speak it?

So, why can’t you use the same approach to learn Java?

Note: To achieve fluency in English or German, these Just a Minute (JAM) and other speaking activities are used on a sustained basis for a period of time.

Learning Java – the labyrinth way

Let’s start with a situation – we need to write a sentence on the screen to show a message.

In our Labyrinth approach,  we start by looking at a Java program to print a sentence –  “This is my first Java program”. The java program is shown as below:


This program is run and the output is shown to the students. Now, the real conceptual session starts.

The trainer explains every part of the program and how do they work together to produce the result.

Let’s understand the structure of the program:

Structure of a Java program

As shown above, the basic structure of a java program comprises of 3 key components.

Most importantly, the Header and entry sections require minimal changes for every program. Only the content section changes for every program, keeping in the mind the end result. To summarize, every Java program has 3 parts:

  • Header Section
  • Entry Section
  • Content Section

Overall structure of the program remains the same. Let’s understand each section.

Header Section of Java program


The header section will typically have two types of statements.

The package statement represents the logical group of programs, you are writing. If you are writing just one program, the package name is not mandatory. However, it’s advisable to use a package to group similar programs. Package name is decided by you.

Import statement is used to indicate the java libraries, you need in your program. So if you are dealing with charts etc, you would need to import the graphics related library by adding it with the import statement.

We used java.lang.* in our first program, because we wanted to print a sentence. Is it easy to know which library to use as your IDE (Eclipse or Netbeans will tell you, if you forget).

Entry section of Java program


The entry section is the easiest one.

The only thing which changes is the class name in “Public class HelloWorld“. HelloWorld is the name of your program. This name will be decided by you.

Content Section of Java program


This is the section, where you have to write your code. In this case, we have written the sentence for printing the sentence This is my first Java program.

Second Java program

Now, you will see that writing the second program will become much easier. Take the following case:

Program Objective – Printing the Square root of 36 in the following format

The square root of 36 is ….

Before you start writing, let me tell you that java has a function namely sqrt() to calculate the square root of a number. The way to use this function is:

Math.sqrt(x) – where x is number of which square root needs to get calculated.

So, how do we write the program? See below:


So, the program code would be:

package Javatutorials;
public class CalSqrt {

public static void main(String[] args) {

System.out.println(“The square root of 16 is:” + Math.sqrt(16));



As you can see, we just needed to change just one line, which was required to print the square root of a number.

At this point, you need to know that Math.sqrt is a function/method to calculate the square root of any number. Secondly, Math is a library but it does not need an explicit import statement. Why? These types of questions should be asked or answered in the class.

Why does this work in case of learning selenium?

Is this the best approach to learn Java for Selenium? Two reasons:

a) This is an easier approach to focus on what is to be learnt? You don’t need to learn Java completely to learn Selenium.

b) This approach allows to learn things conceptually right from the beginning.

Word of caution

Learning language for survival (like German) is one thing. However, learning Java or English for professional world has one more dimension. You need fluency in spoken English to succeed and that is possible through practice.

Same goes with Java. As you learn the concepts in the class, practice simultaneously. You need to write a lot of programs to get a fluency in writing code.

There are plenty of resources available online. Techcanvass provides a course handbook on Java with plenty of examples and practice assignments. These are also available in our learning management system (which gets upgraded every six months).


Learning Java may sound herculean to many of you. But we, at Techcanvass, believe that we have found a relatively easier approach for learning Java.

Part II of this tutorial

Free Java and Selenium Tutorials

Techcanvass is working on developing complete Selenium tutorials starting with Java basics. The tutorials are explained in simple words and you will find it useful to get started.

Free Selenium Tutorials

About Techcanvass

Techcanvass offers IT certification courses for professionals. We are an IIBA endorsed education provider (EEP), iSQI ATP (for Certified Agile Business Analyst Training) as well as Agile Testing alliance partner for CP-SAT certification training in Selenium.

Techcanvass offers following courses on Automation Testing, click on them to explore further

Selenium Training Course
Selenium 3.0 Course
python selenium training
Python Selenium Course
Selenium Certification Course
CP-SAT Certification Course
Agile Automation Testing Training
Agile Automation Testing Training