Problem statement:
what will be the output of the following code?
what will be the output of the following code?
- public class Person extends Thread {
- private int count;
- private Person(int count) {
- this.count = count;
- }
- @Override
- public void run() {
- for (int i = 1; i < 4; i++) {
- count = count + 1;
- }
- }
- public static void main(String[] args) {
- Person t = new Person(10);
- t.start();
- System.out.println(t.count);
- }
- }
Output: 10
output will vary, will explain the reason soon
No comments:
Post a Comment