What Is The Difference Between Compile Time Error and Runtime Error?

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

What is the Difference between compile time error and runtime

error?

Compile time Runtime

The compile time errors are errors which are The runtime errors are errors which are not
produced at the compile time and they are generated by the compiler and produce an
detected by the compiler unpredictable result at execution time

In this case the compiler prevents the code from In this case the compiler does not detects an
execution if it detects an errors in the program errors in the program so it can not prevent the
code from execution

It contains the syntax and semantic errors such It contains the errors such as divison by zero
as missing semicolon at the end of statement determing the square root of a negative number

What is difference between method overloading and method


overriding?
Method overloading Method overriding

Method overloading is a compile time Method overriding is a run time


polymorphism polymorphism
It help to rise the readability of the While it is used to grant the specific
program. implementation of the method which is
already provided by its parent class or
super class
It is occur within the class. While it is performed in two classes
with inheritance relationship.
Method overloading may or may not While method overriding always needs
require inheritance. inheritance

In this, methods must have same name While in this, methods must have same
and different signature. name and same signature.

What is difference between final keyword and final method?


1.Final keywod

-The final keyword in java is used to restrict the user. The java final keyword can be
used in many context. Final can be:

1. variable
2. method
3. class

The final keyword can be applied with the variables, a final variable that have no
value it is called blank final variable or uninitialized final variable. It can be initialized
in the constructor only. The blank final variable can be static also which will be
initialized in the static block only. We will have detailed learning of these. Let's first
learn the basics of final keyword.

2.finalize keyword

final keyword is used in different contexts. First of all, final is a non-access


modifier applicable only to a variable, a method or a class.Following are
different contexts where final is used.

When a variable is declared with final keyword, its value can’t be modified,


essentially, a constant. This also means that you must initialize a final variable. If
the final variable is a reference, this means that the variable cannot be re-bound
to reference another object, but internal state of the object pointed by that
reference variable can be changed i.e. you can add or remove elements
from final array or final collection. It is good practice to represent final variables
in all uppercase, using underscore to separate words.

You might also like