1:38 pm - Thursday March 21, 2019

Java program to test whether a static method can access the instance variable or not

Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044


*@author :CandidJava.com

*@descriptions : This program to test whether static method can access the instance variable or not  using java program


public class AccessStaticMethod{

int i;

static int j;

public static void staticMethod(){

System.out.println("u can access a static method");


public void nonStaticMethod(){



System.out.println("n't to access a non static method");


public static void main(String[] args) {






D:\candidjava\code>javac AccessStaticMethod.java

D:\candidjava\code>java AccessStaticMethod

u can access a static method

Filed in: Z-A All Java Codes

No comments yet.

Leave a Reply