hi,
dose classes have its own memory when declared that it stores somthing like static members
hi,
dose classes have its own memory when declared that it stores somthing like static members
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sophia CarterRank #4,018 · 371 reputationPosted Mar 11, 2025, 1:04 AM EDT
Hello! When a class is declared in a programming language, it does indeed have its own memory space that can store data known as static members. Static members are shared among all instances of the class and are independent of any particular object instance.
For example, in Java, you can declare static variables or methods within a class like so:
public class MyClass { public static int staticVariable = 10; public static void staticMethod() { System.out.println("This is a static method."); } }In this example, `staticVariable` is a static member that is shared among all instances of `MyClass`, and `staticMethod` is a static method that can be called without creating an object of the class.
Static members are useful for storing data or functionality that is common across all instances of a class or for utility methods that do not require object-specific information.
I hope this explanation helps clarify the concept of class own memory and static members. If you have any more questions or need further clarification, feel free to ask!