

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference between Definition and Declaration in Java.
For the difference between definition and declaration, one should consider their literal meaning first which includes Declare means to announce or proclaim while Define means to describe some entity.
The following are the important differences between the Definition and the Declaration.
Sr. No. | Key | Declaration | Definition |
---|---|---|---|
1 | Concept | The concept of declaration includes informing the compiler about properties of the variable such as its name, type of value it holds and the initial value if any it takes. | While the definition is basically the actual implementation and memory location of function and about memory for the variable is allocated during the definition of the variable. |
2 | Exception in C | Both declaration and definition take place at the same time in the case of c language. | In other languages such as Java both occur at different places. |
3 | Number of occurrences | The declaration could be done multiple times either of a variable or of function. | Variable or function could be defined only once. |
4 | Memory allocation | Memory has not been allocated during the declaration of a variable or function. | Memory has been allocated during the definition of a variable or function. |
Example of Declaration vs Definition
JavaTester.java
public class JavaTester{ public static void main(String args[]){ int a; // declaration of variable a=10; // definition of variable functionA(a); // declaration of function } public static void functionA(int a){ System.out.println("value of a is " + a); // definition of function } }
Output
value of a is 10
- Related Questions & Answers
- Explain the Difference Between Definition and Declaration
- What is the difference between declaration and definition in C#?
- What is the difference between a definition and a declaration in C++?
- Internal Table itab declaration in SAP and difference between both the declarations
- Initialization, declaration and assignment terms in Java
- java variable declaration
- Difference between Go and Java.
- Difference between Java and JavaScript.
- Difference Between C++ and Java
- Difference between Java and C language
- Difference between ArrayList and CopyOnWriteArrayList in Java
- Difference between HashMap and ConcurrentHashMap in Java
- Difference between HashTable and HashMap in Java
- Difference between ODBC and JDBC in Java
- Difference between super() and this() in Java
Advertisements