CrazyEngineers Forum - Computer Science & IT Engineering |
Posted: 27 Mar 2011 09:25 PM PDT Hello Friends.....!! If I declare any method as static can have several restriction as... 1) They can only call other static methods. 2) They must only access static data. 3) They cannot refer to this and super in any way... (As per book Herbert Schidt page no: 141) But I wrote a program which is not agreeing with this...Can you please tell me what is static methods and details...I am getting confused..:cry::| The program code is given below.. class operation { static int i = 600; int a,b; void call(int x, int y) { a = x; b = y; } void print() { System.out.println("value of a:"+a+ " value of b:" +b); } static void display() { System.out.println("THis is static method:"); } } class test extends operation { void dis() { System.out.println("value of i: "+i); } static void go() //this method access non-static methods and variables as // it is static { display(); operation e = new operation(); e.a = 111; e.b = 222; e.print(); } } class start extends operation // if I am not extending operation class then it show an { // error cannot find display method as the method is static // I can access it from any where - am I right? public static void main(String ar[]) { test v = new test(); v.go(); v.dis(); display(); } } I am totally confused about static keyword please help....!:cry::cry: |
Sending exe file in email attachment Posted: 27 Mar 2011 07:11 AM PDT How to send an exe file as an attachment in emails? |
You are subscribed to email updates from CrazyEngineers Forum - Computer Science & IT Engineering To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
No comments:
Post a Comment