Android Javascript Ajax Html PHP Example

Android Errors

As we know, there are 3 types of errors.

  1. Syntax Errors
  2. Logical Errors
  3. Runtime Exceptions

So first we’ll move towards the Syntax errors.

What is Syntax?

The set of rules that defines correct structured programs in a programming language is known as syntax.

Example:Here we declare a variable int a, ending with a semicolon. So this is the proper way of writing syntax.

What is the Syntax Error?

If there is an invalid statement written in the program by the programmer, then it is known as a syntax error.

Examples are: forgetting semicolons, curly bracket after if statement etc.

It detects by the compiler and displays the error message without compiling successfully.

Logical Error

Now let’s learn about logical Error.

The logical error is an error in a program that is caused due to poor logic of the source code that results in incorrect or unexpected behavior. Such as wrong output and it may cause a program to crash while running.

As you can see a function declared here average.

Float average in parameter(float a, float b) And it returns a+b/2

As we know on average, summation of total numbers divided by how many numbers we have added.

If you notice in this logic then it will calculate first b/2 and then the result of it will be added with a.

So answer will be obviously comes wrong. This is called as logical error.