- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the difference between compile time errors and run time errors in Java?
Compile time errors are syntactical errors in the code which hinders it from being compiled.
Example
public class Test{ public static void main(String args[]){ System.out.println("Hello") } }
Output
C:\Sample>Javac Test.java Test.java:3: error: ';' expected System.out.println("Hello")
An exception (or exceptional event) is a problem that arises during the execution of a program. When an Exception occurs the normal flow of the program is disrupted and the program/Application terminates abnormally, which is not recommended, therefore, these exceptions are to be handled.
Example
import java.io.File; import java.io.FileReader; public class FilenotFound_Demo { public static void main(String args[]) { File file = new File("E://file.txt"); FileReader fr = new FileReader(file); } }
Output
C:\>javac FilenotFound_Demo.java FilenotFound_Demo.java:8: error: unreported exception FileNotFoundException; must be caught or declared to be thrown FileReader fr = new FileReader(file); ^ 1 error
- Related Articles
- Difference between Compile Time Errors and Runtime Errors in C Program
- What is the difference between compile time polymorphism and runtime polymorphism in java?
- Explain Compile time and Run time initialization in C programming?
- Are Generics applied at compile time or run time?
- Difference between compile-time polymorphism and runtime polymorphism
- What is Java run time environment?
- What is the base class for errors and exceptions in Java?
- What happens in Java Program at compile time?
- What is compile time polymorphism in C#?
- What is terminating and non-terminating errors in PowerShell?
- What is run time polymorphism in C#?
- Using run-time polymorphism in Java
- Run-time Stack mechanism in Java
- Difference between Takt Time and Cycle Time
- What is the effect of errors in Error Detection?

Advertisements