Science, Tech, Math › Computer Science Scope Share Flipboard Email Print Dominik Pabis / Getty Images Computer Science Java Programming PHP Programming Perl Python Javascript Programming Delphi Programming C & C++ Programming Ruby Programming Visual Basic View More By Paul Leahy Paul Leahy Computer Science Expert M.A., Advanced Information Systems, University of Glasgow Paul Leahy is a computer programmer with over a decade of experience working in the IT industry, as both an in-house and vendor-based developer. Learn about our Editorial Process Updated on March 04, 2019 Scope refers to the lifetime and accessibility of a variable. How large the scope is depends on where a variable is declared. For example, if a variable is declared at the top of a class then it will accessible to all of the class methods. If it’s declared in a method then it can only be used in that method. For more information, have a look at the Understanding Variable Scope and Using Modifiers With Variables. Examples: For example, the scope of the variableNUMBER_OF_HOURS_IN_A_DAY is the whole class. Whereas the scope of NUMBER_OF_DAYS_IN_A_WEEK is just the calculateHoursInWeeks public class AllAboutHours{ private final int NUMBER_OF_HOURS_IN_A_DAY = 24; public int calculateHoursInDays(int days) { return days * NUMBER_OF_HOURS_IN_A_DAY; } public int calculateHoursInWeeks(int weeks) { final int NUMBER_OF_DAYS_IN_A_WEEK = 7; return weeks * NUMBER_OF_DAYS_IN_A_WEEK * NUMBER_OF_HOURS_IN_A_DAY; }} Cite this Article Format mla apa chicago Your Citation Leahy, Paul. "Scope." ThoughtCo, Sep. 16, 2020, thoughtco.com/scope-2034287. Leahy, Paul. (2020, September 16). Scope. Retrieved from https://www.thoughtco.com/scope-2034287 Leahy, Paul. "Scope." ThoughtCo. https://www.thoughtco.com/scope-2034287 (accessed June 5, 2023). copy citation Featured Video