Public class A {int x; public static void main(String args[]) {x=x+1;s.o.p(x);}}what is the output? a) compile time errorb) runtime error

This question is related to Oracle Interview

Showing Answers 1 - 5 of 5 Answers

Jay Prakash Dutta

  • Aug 31st, 2006
 

  This program output is -Compile time error..Because int i is non-static variable.we cann't call  non-static variable within static method.

  Was this answer useful?  Yes

bjayprakash

  • Aug 31st, 2006
 

This program output is compile time error. Because int i is non-static variable .we cann't access non-static variable within a static method.

  Was this answer useful?  Yes

tapani

  • Dec 28th, 2006
 

compile time error

  Was this answer useful?  Yes

satyanarayana

  • Aug 14th, 2007
 

Compile time error
In that program int x is an nonstatic variable we can't call directly with static method

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions