There are 2 classes . Class A and Class B. In Class A i declared
a variable in private. if we can access this private variable in
Class B. If yes means , how we can access ?

Answers were Sorted based on User's Feedback



There are 2 classes . Class A and Class B. In Class A i declared a variable in private. if we can a..

Answer / sree

if the variable is private.Declare setter and getters to
the variable and access the varible using the setter and
getters in the other class

Is This Answer Correct ?    34 Yes 1 No

There are 2 classes . Class A and Class B. In Class A i declared a variable in private. if we can a..

Answer / aslam

class B must be inner class of class A

Is This Answer Correct ?    31 Yes 3 No

There are 2 classes . Class A and Class B. In Class A i declared a variable in private. if we can a..

Answer / aslam

There is no freind function in java.

Is This Answer Correct ?    28 Yes 2 No

There are 2 classes . Class A and Class B. In Class A i declared a variable in private. if we can a..

Answer / anant

The variable declared in class a should be directed available
in inner class because.
Getter and setter is also another way.

Is This Answer Correct ?    11 Yes 1 No

There are 2 classes . Class A and Class B. In Class A i declared a variable in private. if we can a..

Answer / sudhakar

private variables are not accessible by the subclasses, either the class B should be the inner class of class A or we have to go through the java reflection api.

Is This Answer Correct ?    0 Yes 1 No

There are 2 classes . Class A and Class B. In Class A i declared a variable in private. if we can a..

Answer / deepak sarao

with the help of friend function u can access private of
class A in class B

Is This Answer Correct ?    5 Yes 19 No

There are 2 classes . Class A and Class B. In Class A i declared a variable in private. if we can a..

Answer / anup

we can easily use of private variable of class A by class B
by inherits by extends keywords as a publicly.then every
variable which are present in base class as behave in derive
class.

Is This Answer Correct ?    1 Yes 25 No

Post New Answer

More J2EE Interview Questions

What are different modules in spring?

0 Answers  


Is j2ee a framework?

0 Answers  


Every field has setter and getter methods.what is happening in this methods.

2 Answers  


can someone tell me how does preparedstatement works? its an interface and where is the implementation?

3 Answers   Satyam, TCS,


What are the main components of a class in java?

0 Answers  






What is j2ee explain the component of j2ee application?

0 Answers  


What is difference between j2ee and java?

0 Answers  


what is interface in java ?can you explain with simple example?and what is the difference between abstract and interface?

0 Answers   HCL,


What does java ee stand for?

0 Answers  


Since we can create managed bean by two ways as, we can define the bean name in faces-config.xml file so that page can use that OR we can write annotation on bean class so that it is automatically assign to page but I want to know which one is good programming practice ? And also mention disadvantage of other which should not prefer ... Thanking you...

0 Answers   ASD Lab,


What is non primitive data type in java?

0 Answers  


explain the technologies that j2ee platform provides for developing components.

0 Answers  


Categories