explain about scope and storage class in oops



explain about scope and storage class in oops..

Answer / Jasvant Singh

In Object-Oriented Programming (OOP), Scope and Storage Class are essential concepts that determine the visibility, accessibility, and lifespan of variables and objects within a program. Here's an explanation of both:

1. Scope:
- Local Variable: Declared within a function or block, visible only within that scope.
- Global Variable: Declared outside any functions or blocks, accessible from anywhere in the program.
- Static Variable: Declared with the `static` keyword, maintained between function calls but still within the same scope.

2. Storage Class:
- Automatic (or auto): Created when a function or block is entered and destroyed once the function or block exits. Example: local variables in C++.
- Static: Allocated and deallocated only once during the entire execution of the program, maintaining its value between function calls. Example: static variables in C++.
- Extern: Declared outside any functions or blocks with no initial value. Used to define global variables that are shared across multiple source files.
- Register: Optimization directive to store a variable in a processor register instead of memory, which can lead to faster access times but limited space. Not supported by all compilers.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Engineering AllOther Interview Questions

which of the following is not a storage class specifier in c?

1 Answers   Infosys,


what is dbms and rdbms??

1 Answers  


Explain a situation in which you handled a customer?s questions or problems?

1 Answers   Kplus Infotech,


what is the formula/ ratio for hollow block? considering to a 40 kgs of portland cement.

1 Answers  


what is static identifier in c language?

1 Answers  


An inversion is an array of numbers is any pair (i,j) such that i<j and A[i]>A[j]. What is the average number of inversions in an array of n distinct numbers? plz GIVE ME SOLUTION

1 Answers   TCS,


sir i have 4 year gap in engineering. i would complete my degree b.tech it in 2014. it will be may be in 2nd class.my hsc is also with 2nd class. i am week in programming. Then if i want highest package upto 5-6 lacs then what should i prepare myself as a good engineer to get this package???

1 Answers  


i need to know abt renault nissan company and the rounds and type of questions asked by today

1 Answers  


explain different access specifiers in class

1 Answers  


compair and contrast procedrual and object oriented programming language

1 Answers  


what is the pri request of binary search

1 Answers  


Which one is more efficient in terms of required memory space call-by-value or call-by-referance?

1 Answers  


Categories
  • Civil Engineering Interview Questions Civil Engineering (5086)
  • Mechanical Engineering Interview Questions Mechanical Engineering (4453)
  • Electrical Engineering Interview Questions Electrical Engineering (16638)
  • Electronics Communications Interview Questions Electronics Communications (3918)
  • Chemical Engineering Interview Questions Chemical Engineering (1095)
  • Aeronautical Engineering Interview Questions Aeronautical Engineering (239)
  • Bio Engineering Interview Questions Bio Engineering (96)
  • Metallurgy Interview Questions Metallurgy (361)
  • Industrial Engineering Interview Questions Industrial Engineering (259)
  • Instrumentation Interview Questions Instrumentation (3014)
  • Automobile Engineering Interview Questions Automobile Engineering (332)
  • Mechatronics Engineering Interview Questions Mechatronics Engineering (97)
  • Marine Engineering Interview Questions Marine Engineering (124)
  • Power Plant Engineering Interview Questions Power Plant Engineering (172)
  • Textile Engineering Interview Questions Textile Engineering (575)
  • Production Engineering Interview Questions Production Engineering (25)
  • Satellite Systems Engineering Interview Questions Satellite Systems Engineering (106)
  • Engineering AllOther Interview Questions Engineering AllOther (1379)