98.6k views
0 votes
What is output? Item jar = new Item(); Item ball = new Item(); System.out.println(Item.count); public class Item{ public static int count = 1; public Item(){ count++; } } Group of answer choices 1 Error: syntax error 3 2

User Pengyang
by
5.2k points

1 Answer

4 votes

Answer:

It's 3

Step-by-step explanation:

now if you pay attention, you've assigned count as 1 in the beginning and you've asked the class to increase the count variable by 1

and when the program is compiled the code is going to count ball and Jar as numbers

mean jar.count is 2

and ball.count is 3

that's all

User Cavachon
by
5.2k points