Question

describe three types of errors. Construct an example that uses each of these types of error....

describe three types of errors.

Construct an example that uses each of these types of error.
Describe which type of error you're using and how your example generates that type of error.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

there are three types of errors

  1. Syntax Errors - syntax error is also known as a compile-time error, this error stops code from compiling because of missing syntax in code, this error includes missing braces or wrong class name or can be class not found. the syntax error is detected by the compiler.
    for eg:- A very common Syntax error these days missing semicolon at the end of statement for some programming languages it is must and the source code won't be executed(';' is must in java at the end of the statement where as in kotlin it is optional.)
    System.out.print("a semicolon is missing at the end is error")
  2. Logical Errors - it is an error made by a programmer and can not be detected by the compiler, this is due to the wrong idea and wrong concept of programming language.   
    for eg:- the == is the most common error is the equivalent operator & assignment operator confusion,
    int a == 20; it is a logical error, the correct logic is assigning the value to a i.e. int a = 20;
  3. Runtime Errors - it is a type of error that is not detected by the compiler, it occurs when program is running.
    for eg:- upon clicking three the third page must open but instead it leads to fourth page it is a bug and this type of error can not be detected by compiler.

example that uses each of these types of error.

in java:

for (int i=0; i<=2; i++){

if(i = 1){

System.out.println("the value of i is 0")

}

}

the above code has all the three types of error:

1. missing ; at the end of statement System.out.println("the value of i is 0") -- syntax error

2. if (i=1) is a logical error, equivalent operator must have been used intead

3. System.out.println("the value of i is 0"), is runtime compiler error or bug, the value of i is wrong printed on screen according to logic the value of i must be 1.

Add a comment
Know the answer?
Add Answer to:
describe three types of errors. Construct an example that uses each of these types of error....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT