Question

What is the output of the following Java code? class Counter {     static int count = 0;     Counter() { count++; } } public class Main {     public static void main(String[] args) {         new Counter();          new Counter();          new Counter();         System.out.println(Counter.count);     } }

B 3
C Compilation error: static count cannot be incremented in a constructor
D 9
E 1
Practice Next

Hey! Ask a query

🎓
Think You're Ready for RBI Grade B?
RBI Grade B 2026 Phase 1 Memory Based Paper
  • 200 Questions with Detailed Solutions
  • Section-wise Coverage (GA, English, Quant & Reasoning)