Home » Interview » Technology

When this. non-static datamember is compulsory inside non-static method

Correct Answer: Whenever there is local- variable/parameter inside the method with same name as data member Ex: Class Sample { int a; void show() { int a=5; systemoutprintln(a); // 5 systemoutprintln(thisa);//23 } } class MainApp { Public static void main(String[] args) { Sample s = new Sample(); sa = 23; sshow(); } }

← Previous Question Next Question→

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion