Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Java
  3. Question
Java

Variables that are shared by every instance of a class are?

Asked by Arjun Arora Oct 13, 2022 1.1K views 1 answer
Share

About this question

I'm very new to Java and want to understand the difference between class variables and instance variables.


For example:


class Bicycle { 
    static int cadence = 0; 
    int speed = 0; 
    int gear = 1; 
}

How are instance variables and class variables different from each other? Which variables here are class variables, and which are instance variables? How does this affect scope?

Your answer

1 Answer

More Java discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Java Blogs

Guides, tips and career advice on Java from JanBask experts.