Kindly post answers for these ..please for all my questions with question numbers .. class wo { static int sum( int a, int b) { return (a+b); } }
class wer { static int b=4,c=6; public static void main (String args[]) { int a; a=wo.sum(c,b); System.out.println(a); } } 1)In this program when i say int a; does that mean it is a static datamember as i have declared inside a static main method or is that a local variable ?
2) if i declare int b=4,c=6 inside main does that mean they are static members ..if they are local members how can a static method ( int sum(int a,int b ) can access local members ?since rule says static method can access only static members..
3) if static method can access static members(rule according to java ) why am i unable to declare static int b=4 , c=6 inside main and print the sum using this called method static int sum(int a, int b) { return (a+b); }
4)Is there any situation like this in java
class a { public static void main (String args[]) { void display() { System.out.println("asldjflaj"); } } I do know that its a compile time error I do know that we cant write method defintion inside a method..am i right.or is there any different supporting statement for this ?
5) is there any chance in java to make a method or a data member static without preceding with the keyword static ?
if i say static int a() { int b;//is this a static member or a local variable or instance member }
Alex Belisle Turcot
Ranch Hand
Joined: Apr 26, 2005
Posts: 516
posted
0
Hi,
You should rather post these questions in the "programmer" forum: