Compile time errors are detected at the compilation of a program. These are usually syntactical errors. A program cannot be compiled and hence executed if it contains a compile time error.
for example,
int a b=0;
above statement will produce a compile time error as a and b must be separated by a comma(,).
Runtime errors are logical errors. They don't affect the compilation of the program but causes a program to produce unwanted output. The program becomes buggy.
for example,
sum=sum-a[i];
in above statement, no syntactical error is present and hence the program will get executed successfully. But from a logical point of view, sum was supposed to be the addition of array elements. using minus(-) instead of plus(+) will give unwanted or incorrect output.
C is a high level language which means it is meant for humans to understand not computers. For a computer to understand a C program it has to be compiled, that is changed into machine language. Once a program is in machine language then the computer can understand it and perform the actions it describes (that is to run the program). A C program need only be compiled once but (once compiled) it can be run any number of times.
Polymorphism is defined as one interface to control access to a general class of actions. There are two types of polymorphism one is compile time polymorphism and the other is run time polymorphism. Compile time polymorphism is functions and operators overloading. Runtime time polymorphism is done using inheritance and virtual functions.
Polymorphism means that functions assume different forms at different times. In case of compile time it is called function overloading. For example, a program can consist of two functions where one can perform integer addition and other can perform addition of floating point numbers but the name of the functions can be same such as add. The function add() is said to be overloaded. Two or more functions can have same name but their parameter list should be different either in terms of parameters or their data types. The functions which differ only in their return types cannot be overloaded. The compiler will select the right function depending on the type of parameters passed. In cases of classes constructors could be overloaded as there can be both initialized and uninitialized objects. Here is a program which illustrates the working of compile time function overloading and constructor overloading.
eg.
namespace CommonClasses { public interface IAnimal { string Name { get; } string Talk(); } } // Assembly: Animals using System; using CommonClasses; namespace Animals { public abstract class AnimalBase { public string Name { get; private set; } protected AnimalBase(string name) { Name = name; } } public class Cat : AnimalBase, IAnimal { public Cat(string name) : base(name) { } public string Talk() { return "Meowww!"; } } public class Dog : AnimalBase, IAnimal { public Dog(string name) : base(name) { } public string Talk() { return "Arf! Arf!"; } } } // Assembly: Program // References and Uses Assemblies: Common Classes, Animals using System; using System.Collections.Generic; using Animals; using CommonClasses; namespace Program { public class TestAnimals { // prints the following: // Missy: Meowww! // Mr. Bojangles: Meowww! // Lassie: Arf! Arf! // public static void Main(string[] args) { var animals = new ListA compile-time error occurs when you attempt to compile the program, for example a syntax error.
A run-time error occurs when you are running the program, for example the program asks you for a number, you enter a letter and the program crashes.
Compilation time & execution time are diff to each other.When an instruction given by the user is performed by the processor,it is said that the particular instruction or command is executing.But before executing any instruction or a set of instruction,i.e.,a program,it is necessary to check whether the command given is given properly or whether the program is syntactical errorfree.This checking is called compilation.This job is done by the compiler or interpreter ont by the processor itself.
If the ans helps you,plz increase the trust point.
It was asked in an interview of mine, I could only tell that compiler selects method to call at runtime.
Lets say for example
Base b=new Derived();
b.someMethod();
What actually happens in compile time and runtime in above part.......
Expect answers from geeks only plz...... :)
Here's an answer from a geek: RTFM and stop bothering me (8^). The specification for method expression invocation can be found https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.12
The spec will give you all the details but in short:
Compilation: During compilation all the compiler cares about is finding the method signature. In your example "someMethod()" is what is written in the code and that's all there is to it. This is known as "static binding".
Runtime: When the program is running the JVM calls the "someMethod()" implementation that is appropriate for the runtime object referenced by "b". The variable "b" is a reference to the "Derived" object so the method defined in "Derived" is called. the JVM does what is called "method dispatch", also known as as "dynamic binding" (it happens dynamically).
Very simply, Java compile time is when Java is in the process of compiling source code, and run time is when Java is actually executing your program.
Compile time refers to when the compiler is turning source code into machine code.
Runtime refers to when your process is actually executing.
(Please don't advertise here.)
When you compile your project, you are in compile time. Runtime occurs when you execute the machine code generated by the linker (after compile time).
"run time" is the opposite of "compile time". It refers to the time when the program is actually running.
Linkage time.
Compile Time: In longer form, you might say, "at the time of compiling", or, "when the program is compiled". When you compile a program, the compiler applies various processes to your source code in order to generate the executable files. These are actions that happen "at compile time". Other actions happen when you actually run the finished program. These actions are said to occur, at, or in, "run time".
Interpreted means - normally - the code is interpreted at run-time, while parsed (actually, it's "compiled") means the code is translated to a native object file at compile-time, and then executed. Compiled code is usually faster, also.
Static polymorphism is used the concept of early binding or we can say compile time binding where as dynamic polymorphism used the concept of late binding or run time binding.
Runtime prolymorphism means overriding compiletile polymorphism means overloading
Assuming you are refering to software development: Design time - Prior to compile Run time - After compile, while program is running Break time - Pausing the execution of code during the debugging process
A run-time is an error that occurs when the program is executing (running). This is where segfaults and other horrible things happen. A compile-time error is an error that occurs when you are compiling the code. This is where code syntax and semantics are checked. You want errors to only occur here.
compile time
A run-time is an error that occurs when the program is executing (running). This is where segfaults and other horrible things happen. A compile-time error is an error that occurs when you are compiling the code. This is where code syntax and semantics are checked. You want errors to only occur here.
Compile time is when the compiler translates your source code into computer language. Run time is when the actual program runs.
Statically typed languages check type of variable at Compile time vs Dynamically typed language check type at run time
"run time" is the opposite of "compile time". It refers to the time when the program is actually running.
Dynamic memory can be declared at run-time using the new and delete operators (or malloc and free in C), while static memory must be declared at compile-time.
Linkage time.
run-time error definition. An error in the execution of a program which occurs at run time, as opposed to a compile-time error. A good programming language should, among other things, aim to replace run-time errors by compile-time errors.
Compile Time: In longer form, you might say, "at the time of compiling", or, "when the program is compiled". When you compile a program, the compiler applies various processes to your source code in order to generate the executable files. These are actions that happen "at compile time". Other actions happen when you actually run the finished program. These actions are said to occur, at, or in, "run time".