---
title: "What are local and instance variables in Java ?"  
description: "What are local and instance variables in Java ?"  
author: "Devesh Kumar Singh"  
published: 2015-11-24  
updated: 2020-09-17  
canonical: https://www.mindstick.com/interview/22913/what-are-local-and-instance-variables-in-java  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# What are local and instance variables in Java ?

Local variables are those which are declared within a block of code like methods. Local variables should be initialized before accessing them, whereas

Instance variables are those which are defined at the class level. Instance variables need not be initialized before using them as they are automatically initialized to their default values.

## Answers

### Answer by Devesh Kumar Singh

Local variables are those which are declared within a block of code like methods. Local variables should be initialized before accessing them, whereas

Instance variables are those which are defined at the class level. Instance variables need not be initialized before using them as they are automatically initialized to their default values.


---

Original Source: https://www.mindstick.com/interview/22913/what-are-local-and-instance-variables-in-java

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
