ALLInterview.com :: Home Page            
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Google
   
 
Categories >> Software >> Programming Languages >> C++ >> OOPS
 
 


 

 
 STL interview questions  STL Interview Questions (93)
 OOPS interview questions  OOPS Interview Questions (563)
 C++ General interview questions  C++ General Interview Questions (461)
Question
What is the difference between declaration and definition?
 Question Submitted By :: OOPS
I also faced this Question!!     Answer Posted By  
 
Answer
# 1
During declaration we just specify the type and no memory
is allocated to the variable. But during the definition an
initial value is assigned and memory is allocated to the
variable.
 
Is This Answer Correct ?    180 Yes 31 No
Roshan
 
Answer
# 2
Declaration means we are just creating a variable or method.
Defination means we are assigning some value for a variable
& doing some functions in method
 
Is This Answer Correct ?    111 Yes 47 No
S
 
 
 
Answer
# 3
The definition is the one that actually allocates space,
and provides an initialization value, if any.
There can be many declarations, but there must be exactly
one definition. A definition tells the compiler to set
aside storage for the variable. A declaration makes the
variable known to parts of the program that may wish to use
it. A variable might be defined and declared in the same
statement
 
Is This Answer Correct ?    53 Yes 4 No
Sanjay
 
Answer
# 4
Ans: The declaration is means the memory is not yet all to
be allocated..
For example:
Int a; //is it declaration? Or definition?
Just check this
Int main()
{
Int I;
Printf(%d,i);
}
It prints the garbage value that means the memory is
allocated for this declaration so we can say that this int I
is both declaration and definition.
And take another example extern int I -- declaration
because no memory is allocated.
Similarly for function prototypes all are declarations.
In the case of class declaration String s; // Declaration
[because reference is created]
When the new keyweord encounters then it is definition
String *s=new Stirng(); //declaration and
definition
 
Is This Answer Correct ?    36 Yes 3 No
Rajesh Manem
 
Answer
# 5
Declaration means just telling to complier about variable
or function but definition means actually allocating memory
for variable.
 
Is This Answer Correct ?    24 Yes 4 No
Omkar
 
Answer
# 6
Declaration Mean You just Declare a variable and Function
their is No Allocation of Memory.But In Defination Actual
use of use declare Variable and Function Assing the value
with accupy Memory as Per their Type.
 
Is This Answer Correct ?    11 Yes 6 No
Sachin Bhosale
 
Answer
# 7
Declaration means it exits but it has no meaning. But where
as definition means it has a meaning. Without decalration
there is no definition. Why means without existing how can
we use.
Some situations we do both in a single statement like,
int i = 10;
here i is declared and definie with the value 10;
But some languages give some value to the variable without
defining like
class DiffsDemo {
int i;
}

DiffsDemo demo = new DiffsDemo();
print: demo.i;
output: 0;

This will happen because some default values are assigned
to that types. Internally at run time they will define.
 
Is This Answer Correct ?    8 Yes 5 No
Krishna Chowdary Garapati
 
Answer
# 8
The declaration tells the compiler that at some later point
we plan to present the definition of this declaration.
E.g.: void stars () //function declaration
The definition contains the actual implementation.
E.g.: void stars () // declarator
{
for(int j=10; j > =0; j--) //function body
cout << *;
cout << endl; }
 
Is This Answer Correct ?    4 Yes 1 No
Friend Nitk
 
Answer
# 9
Declaration of a function is COMPILATION PHASE,inorder to
support the SIGNATURE OF FUNCTION like function
name,arguments. Simply it identifies FUNCTION.

Where as in defination, function cotains SET OF
STATEMENTS and expands SOURCE CODE in the form of
instructions
(all this is concept of functions)
 
Is This Answer Correct ?    3 Yes 1 No
Ganesh9948302505
 
Answer
# 10
Declaration of a variable means name the variable and tells
compiler that this has been present elsewhere in the program
Definition means that allocate or reserve some space and
store the value in that variable.
the variables like auto and registers, the declaration and
definition done at the same time because they are named the
variable and allocate the memory at the same time.
Ex- int a;//declaration and definition
extern int a;//only declaration
once the variable is defined it is ready to hold the data
value needed by the program
 
Is This Answer Correct ?    0 Yes 0 No
Durga Devi Sathi
 

 
 
 
Other OOPS Interview Questions
 
  Question Asked @ Answers
 
what is oops DELL 4
different types of castings Siemens 3
what is the usage of clas templates   5
should we use linear search or binary search if elements are placed in random order or mixed?in both cases? i need a little bit detail ans?thnks   2
what is the use of mutable key word HCL 3
to remove the repeated numbers from the given . i.e.., if the input is 12233 output should of 123   2
what do you mean by static member variable?   2
What is the difference between and interface and an abstract class ? Ness-Technologies 4
i ahve v low % in 12th n BSC which is aroun 50 coz science was imposed on me......nw m doin MCA n my aggregate in above 74%,what shud i say if asked about low previous percentage??????   4
What is virtual destructor? Why? CSC 3
What is abstrac class?where is it use?   1
what is new operator in c++   1
 
For more OOPS Interview Questions Click Here 
 
 
 
 
 


   
Copyright Policy  |  Terms of Service  |  Articles  |  Site Map  |  RSS Site Map  |  Contact Us
   
Copyright 2013  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  KalAajKal.com