What is static?

Technical
Easy
Infosys
92.5K views

Tests understanding of the static keyword in programming languages like Java or C++.

Why Interviewers Ask This

The static keyword is frequently used in programming. Interviewers ask this to check if the candidate understands class-level variables and methods versus instance-level ones. It is a common topic in coding interviews.

How to Answer This Question

Explain that static members belong to the class rather than any specific instance. Mention that they are shared across all instances and exist even if no objects are created. Discuss common uses like utility methods or constants. Clarify memory allocation differences.

Key Points to Cover

  • Class-level membership
  • Shared across instances
  • Memory allocation
  • Common use cases

Sample Answer

In programming, the static keyword indicates that a member variable or method belongs to the class itself, not to any specific instance. Static members are shared among all objects of the class and are initialized when the class is loaded. For example, a static counter can track the total number of objects created. This is useful for utility functions or constants that do not depend on instance state.

Common Mistakes to Avoid

  • Confusing with final keyword
  • Thinking static means constant
  • Ignoring initialization timing

Practice This Question with AI

Answer this question orally or via text and get instant AI-powered feedback on your response quality, structure, and delivery.

Start Practicing

Related Interview Questions

Browse all 78 Technical questionsBrowse all 65 Infosys questions