logo

Crowdly

What is the output of the following code snippet? class MyClass {     stat...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

What is the output of the following code snippet?

class MyClass {

    static int count = 0;

    public MyClass() {

        count++;

    }

    public static int getCount() {

        return count;

    }

}

public class

Main {

    public static void main(String[] args) {

        MyClass obj1 = new MyClass();

        MyClass obj2 = new MyClass();

        System.out.println(MyClass.getCount());

    }

}

0%
0%
0%
More questions like this

Want instant access to all verified answers on my.uopeople.edu?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!