Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9125903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:54:46+00:00 2026-06-17T06:54:46+00:00

Let there be three classes named Tester_1 , Tester_2 , Tester_3 . They are

  • 0

Let there be three classes named Tester_1 ,Tester_2,Tester_3. They are defined as :

Tester_1:

class Tester_1 {

 public static void main(String args[]) {
    Tester_2.setBoolean(true);
    System.out.println(Tester_2.getBoolean());
 }
}

Tester_2:

class Tester_2 {

public static boolean var = false; // Static var

public static void setBoolean(boolean value) {
   var = value;
}

public static boolean getBoolean() {
    return var;
}

}

Tester_3:

class Tester_3 {
public static void main(String args[]) {
    System.out.println(Tester_2.getBoolean());
}
}

After I compile all the three classes, I run them in the following order :

java Tester_1

java Tester_3

but I get this output :

true from the first run and false from the second run. Why is that ? When Tester_1 sets the boolean to a value true why do I get the default false when I run Tester_3 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:54:47+00:00Added an answer on June 17, 2026 at 6:54 am

    static is only valid at the Java Virtual Machine (JVM) level.

    Each time you call java xxx you create a new JVM which does not share anything with the previous call => all static variables get their default value again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's assume there is a static .Net method static void RegisterDelegate(Action<array<Object^>^>^ handler); defined in
So let's say we have a class named Car and three other classes (Opel
Let's say I have three classes set up as follows: abstract Class A {
Let's say I have a base class named BaseClass: public BaseClase{ public bool isCool;
Let's say that I have classes like this: public class Parent { public int
let's say I have 200 classes named class1, class2, etc derived from class, and
Let's say I have a Base class and several Derived classes. Is there any
There are two classes, let's call them X and O. A number of elements
Are there any easy-to-use , high-level classes or libraries that let you interact with
Let's say I have a nontrivial tree of dependencies between classes. There are no

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.