0
What is the o/p of this programming code ??
class A { int x; A(int x) {x = x ;} void display() { System.out.println(x); } } public class B { public static void main(String[] args) { A a = new A(7); a.display(); } }
4 Respostas
+ 1
You've tag your question with "javascript" and "java" Oo !
This is java, not javascript : totally differents ones ^^
Try to replace {x = x ;} by {this.x = x ;}
Else you attribute the value of your parameter to... your parameter :P ( due to scope )
And maybe you need too to prefix your A class by the keyword "public" ?
0
0
0
use...this.x=x;........to get 7
0
ohh ya this is absolutely right #somnath or visph and thanx for my mistake to tag a javascript