why i can not access private variable in other class?

Answer Posted / srihari

private variables are visible within the class they are
defined but not in the other classes present in same package
& classes in different packages. Hence, we call "private"
variables as "CLASS-LEVEL" instances.

private variables are used when we do not want the variable
declared in a class to be shared or used by other classes
present in same packages or different packages.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I open my java console?

497


Can we write lambda without functional interface?

453


How does java handle integer overflows and underflows?

511


Why do we need framework in java?

439


Which is better openjdk or oracle jdk?

454






What gives java it’s “write once and run anywhere” nature?

474


What is proxy object in java?

570


Is java installed on windows 10?

474


Are streams faster than for loops?

496


What is injection in java?

474


Explain main thread under thread class execution?

483


What is the java virtual machine (jvm)?

604


For each of the following program segments,give a big zero analysis for the running time 1.For (i=0;i

1502


can anyone tell me what kind of questions are asked for core java exam in aptech

1454


Describe the principles of oops.

496