Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Java Programming Language Interviews:Advanced JavaCore JavaEclipseFull Stack Developer (Java)HibernateIBM WebSphereInternationalization LocalizationJ2EEJ2MEJ2SEJavaJava ANTJava AppletJava BeansJava ClassesJava EJB ProgrammingJava Game DeveloperJava GUI FrameworkJava JNDIJava JNIJava JSP ProgrammingJava Message Service (JMS)Java Multi-ThreadingJava Networking - Sockets and RMIJava PatternsJava SecurityJava Server FacesJava Servlet ProgrammingJava Software EngineerJava Swing ProgrammingJava TechnicalJava ThreadsJava Transaction APIJava Web ServicesJavaMailJBossJDBCJMSJSFPortal and PortletRMISpring FrameworkSr.Java Web DeveloperStrutsSunOneSwing AWTSWT JFace
Copyright © 2018. All Rights Reserved
Java Game Developer Interview Question:
What is the meaning and the use of the static keyword in java?
Submitted by: MuhammadStatic is a commonly used keyword, which is associated with variables, methods and nested classes in java. The real use of the keyword is for memory management of these constructs, as detailed next.
1)Static variables in java
When a variable is created as static in Java, it gets memory allocated to it only once, and that too when the class in which it is declared gets loaded. This is the reason why these variables are used to declare properties of other variables which are shared amongst them and do not change.
2)Static methods in java
Methods in java can also be declared as static, and as such, these are then connected to the entire class, without being limited to any single object of the class. Invocation of such a method declared as static does not require the instance of the class and these methods can work on the static data of the class and can even make updates to the value of static constants and variables.
This is also the reason why the main function in java is by default static and hence no object is required to invoke it and this leads to a better memory management.
Submitted by: Muhammad
1)Static variables in java
When a variable is created as static in Java, it gets memory allocated to it only once, and that too when the class in which it is declared gets loaded. This is the reason why these variables are used to declare properties of other variables which are shared amongst them and do not change.
2)Static methods in java
Methods in java can also be declared as static, and as such, these are then connected to the entire class, without being limited to any single object of the class. Invocation of such a method declared as static does not require the instance of the class and these methods can work on the static data of the class and can even make updates to the value of static constants and variables.
This is also the reason why the main function in java is by default static and hence no object is required to invoke it and this leads to a better memory management.
Submitted by: Muhammad
Copyright 2007-2025 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.