why i can not access private variable in other class?

Answers were Sorted based on User's Feedback



why i can not access private variable in other class?..

Answer / naresh

private variable are visible within it class only. the are
not visible to other class within that package or other. so
we cannot access.

Is This Answer Correct ?    7 Yes 0 No

why i can not access private variable in other class?..

Answer / srinu

private variable are visible in the with in class only.This
are not accessble to other class with in same package or
other diiferent package .so we can't access the private
variable out side of classes

Is This Answer Correct ?    4 Yes 0 No

why i can not access private variable in other class?..

Answer / 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

why i can not access private variable in other class?..

Answer / maggie

it cant access.because its life time only within the class
or loop.it expires when it comes out from the class or loop.

Is This Answer Correct ?    1 Yes 3 No

Post New Answer

More Java Related AllOther Interview Questions

What is war file in java?

0 Answers  


What is maven in java?

0 Answers  


What is the use of entity class in java?

0 Answers  


what is reflection api? How are they implemented?

0 Answers  


Write a program for the problem: the array of inetegers indicating the marks of the students is given, U have to calculate the percentile of the students aaccording to this rule: the percentile of a student is the %of no of student having marks less then him. For eg: suppose Student Marks A 12 B 60 C 80 D 71 E 30 F 45 percentile of C = 5/5 *100 = 100 (out of 5 students 5 are having marks less then him) percentile of B = 3/5*100 = 60% (out of 5, 3 have markses less then him) percentile of A = 0/5*100 = 0%.

0 Answers   Sapient,


What is jpa implementation?

0 Answers  


What is Map,List,hashtable,ArrayList and difference between them??

0 Answers   Cap Gemini, TCS,


Do I need to install jre if I have jdk?

0 Answers  


Explain the Sequence Diagram?

2 Answers   HCL,


suppose we have one String s="india is my country"; now we get the o/p "like country my is India". what is the logic?

2 Answers  


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

1 Answers  


What is the use of lambda functions?

0 Answers  


Categories